简体   繁体   中英

Show signature in all pages of PDF using iTextSharp

Hello I am wanting to show the digital signature on all pages of the PDF, I researched but only found a method that inserts an image on all pages, but my certificate has no image, can someone help me. Below, a piece of code:

sap.SetVisibleSignature( new iTextSharp.text.Rectangle( 10f, 10f, 110f, 30f ), reader.NumberOfPages, null );
sap.SignDate = DateTime.Now;
sap.Acro6Layers = true;
PdfSignature dic = new PdfSignature( PdfName.ADOBE_PPKMS, PdfName.ADBE_PKCS7_SHA1 );
dic.Date = new PdfDate( sap.SignDate );
signName = iTextSharp.text.pdf.security.CertificateInfo.GetSubjectFields( sap.Certificate ).GetField( "CN" );
dic.Name = signName;

if ( sap.Reason != null ) dic.Reason = sap.Reason;
if ( sap.Location != null ) dic.Location = sap.Location;

his code only shows the signature on the last page of the PDF.

I've taken a screen shot from the draft of the upcoming specification.

在此处输入图片说明

You're asking to have one signature that is represented by multiple widget annotations (one on each page). However, the spec says:

signature fields shall never refer to more than one annotation.

Whenever the spec uses the word shall , any PDF not obeying the spec is considered invalid. (In case the spec is only recommending something, the word should is used.)

Summarized: you're asking something that isn't allowed (for now: not recommended; in the future: forbidden).

Extra remark: a digital signature in a PDF covers the whole document. There is no use to put a visual mark on each page because that would encourage the misconception that digital signatures in PDF can be used to sign separate pages. The reason to add the one signature = one widget annotation in the ISO specification is also educational: whoever demands a widget annotation on every page for a single signature, proves that he or she doesn't understand the concept of digital signatures in PDF ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM