Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to apply Digital Signature to PDF with multiple pages in asp.net wit c#. I am using Itextsharp dll.
I tried using pdfsignature class and was able to set the digital sign, But I need to apply multiple signatures to the PDF. I am able to apply only to a single page even on clearing a new object for pdfsignature class.

What I have tried:

PdfSignatureAppearance sap = st.SignatureAppearance;

           sap.SetCrypto(this.myCert.Akp, this.myCert.Chain, null, PdfSignatureAppearance.WINCER_SIGNED);
           sap.Reason = SigReason;
           sap.Contact = SigContact;
           sap.Location = SigLocation;
           string SourcePDFFullPath = @"F:\Test.pdf";
           PdfReader pdfReader = new PdfReader(SourcePDFFullPath);

PdfSignatureAppearance sap1 = st.SignatureAppearance;

           sap1.SetCrypto(this.myCert.Akp, this.myCert.Chain, null, PdfSignatureAppearance.WINCER_SIGNED);
           sap1.Reason = SigReason;
           sap1.Contact = SigContact;
           sap1.Location = SigLocation;
           string SourcePDFFullPath = @"F:\Test.pdf";
           PdfReader pdfReader = new PdfReader(SourcePDFFullPath);


               sap.SetVisibleSignature(new iTextSharp.text.Rectangle(100, 100, 250, 150), 1, null);
               sap1.SetVisibleSignature(new iTextSharp.text.Rectangle(100, 100, 250, 150), 2, null);
Posted
Updated 26-Jun-19 10:47am
Comments
Afzaal Ahmad Zeeshan 20-Jun-19 12:45pm    
Tried iterating over the pages and applying a signature to each?
Maciej Los 26-Jun-19 16:41pm    
Or do you want to add multiple signatures?

1 solution

Please, read comments to the question first.

Take a look here: c# - ITextSharp SetVisibleSignature not working as expected - Stack Overflow[^]
There's some issue with iText(Sharp) 5.5.7 and higher, which is able to resolve by using code provided in accepted answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900