Signing a PDF with iTextSharp

11,506

Solution 1

PDF signing has been refactored in iText 5.3.0 and a white paper is currently being written about the new signing process. The final version should be published in September.

You'll find more information here.

Solution 2

the book examples are already adapted to iText 5.3.0: http://itextpdf.com/book/chapter.php?id=12

Share:
11,506
Master_T
Author by

Master_T

Updated on June 04, 2022

Comments

  • Master_T
    Master_T almost 2 years

    I've been using iTextSharp to sign PDFs in my application, and it works pretty good using this code I adapted from the java example on the iText website:

    PdfStamper stp = PdfStamper.CreateSignature(reader, outmemstream, ControlChars.NullChar);
    PdfSignatureAppearance sap = stp.SignatureAppearance;
    sap.SetCrypto(prvKey, new X509Certificate[] {sigCert, Repository.CAcertificate}, null, pdfSignatureAppearance.SELF_SIGNED);
    sap.Reason = "Just to proove I can sign!";
    

    This has worked ok until version 5.2.1 of iText, but in the recent version 5.3.0 the "SetCrypto" method has been removed and I cannot sign anymore! Any ideas on why it has been removed and what may be an alternative method to sign a pdf on the new version??

    Thanks in advance