当我签署文档时,签名仅出现在第一页上。我能做些什么让它出现在每一页上吗?这是我现在用来签署PDF的方法,希望它有助于找到解决方案:
public static PdfStamper SignHashedUser(string Target, SysX509.X509Certificate2 Certificate, string Reason, string Location, bool AddVisibleSign, PdfReader objReader, int pags)
{
X509CertificateParser objCP = new X509CertificateParser();
X509Certificate[] objChain = new X509Certificate[] { objCP.ReadCertificate(Certificate.RawData) };
PdfStamper objStamper = PdfStamper.CreateSignature(objReader, new FileStream(Target, FileMode.Create), '\0');
PdfSignatureAppearance objSA = objStamper.SignatureAppearance;
int[] perms = { PdfWriter.AllowPrinting, PdfWriter.AllowFillIn };
if (AddVisibleSign)
objSA.SetVisibleSignature(new Rectangle(50, 50, 250, 100), pags, null);
//pags define in which page of the PDF will the signature appear
objSA.SignDate = DateTime.Now;
objSA.SetCrypto(null, objChain, null, null);
objSA.Acro6Layers = true;
objSA.Render = PdfSignatureAppearance.SignatureRender.NameAndDescription;
PdfSignature objSignature = new PdfSignature(PdfName.ADOBE_PPKMS, PdfName.ADBE_PKCS7_SHA1);
objSignature.Date = new PdfDate(objSA.SignDate);
objSignature.Name = PdfPKCS7.GetSubjectFields(objChain[0]).GetField("CN");
if (objSA.Reason != null)
objSignature.Reason = objSA.Reason;
if (objSA.Location != null)
objSignature.Location = objSA.Location;
objSA.CryptoDictionary = objSignature;
int intCSize = 4000;
Hashtable objTable = new Hashtable();
objTable[PdfName.CONTENTS] = intCSize * 2 + 2;
objSA.PreClose(objTable);
HashAlgorithm objSHA1 = new SHA1CryptoServiceProvider();
Stream objStream = objSA.RangeStream;
int intRead = 0;
byte[] bytBuffer = new byte[8192];
while ((intRead = objStream.Read(bytBuffer, 0, 8192)) > 0)
objSHA1.TransformBlock(bytBuffer, 0, intRead, bytBuffer, 0);
objSHA1.TransformFinalBlock(bytBuffer, 0, 0);
byte[] bytPK = SignMsg(objSHA1.Hash, Certificate, false);
byte[] bytOut = new byte[intCSize];
PdfDictionary objDict = new PdfDictionary();
Array.Copy(bytPK, 0, bytOut, 0, bytPK.Length);
objDict.Put(PdfName.CONTENTS, new PdfString(bytOut).SetHexWriting(true));
objSA.Close(objDict);
return objStamper;
}
编辑:PdfSignatureAppearance.SetVisibleSignature()是一种方法,包括一个参数,指示应该显示签名的页面。但是,它不能用于确定将显示一个人的签名的页数。
答案 0 :(得分:2)
请允许我复制ISO-32000-2中的句子和注释。此文档尚未提供,因为它只会在2016年发布。但是,这个问题的主题非常明确:
但这始终如此:它仅在Adobe专有的文档中记录。从PDF 2.0开始,它将是规范性的。
简而言之:您要求的内容违反了PDF规范。
答案 1 :(得分:0)
实际上,您可能有一个签名字段和一个相应的窗口小部件注释,并且还将表示此签名的图像或其他对象放在所有其他位置。