Digital Signatures

Digitally signing a PDF document helps to ensure the document's integrity by providing a method of adding authentication to the PDF itself. With IronPDF, you have several options when it comes to signing a new or existing PDF file. These are either digitally signing the PDF document with a certificate, adding a graphical handwritten version of your signature to the PDF, stamping an image of the certificate on the PDF, or simply creating a signature form field on the PDF to prompt user signing.

Steps to Digitally Signing a PDF with IronPDF

  • var renderer = new ChromePdfRenderer();
  • var doc = renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>");
  • var signature = new IronPdf.Signing.PdfSignature("Iron.pfx", "123456") { SigningContact = "support@ironsoftware.com", SigningLocation = "Chicago, USA", SigningReason = "To show how to sign a PDF" };
  • doc.Sign(signature);
  • doc.SaveAs("signed.pdf");

The first step in this process is to either load in or create the PDF we want to sign. For this example, we will be creating a new PDF document from HTML content. To do this, you will first need to create a new ChromePdfRenderer instance. This is IronPDF's powerful rendering engine used to render HTML, CSS, and JavaScript to PDF without losing quality. We then use the RenderHtmlAsPdf method to render our HTML string into a high-quality PDF document ready to be signed. The resulting PDF is stored in the doc variable.

Next, we need to create our signature. For today's example, we will sign our PDF document with a certificate. PdfSignature represents the digital signature object for signing the PDF, and it requires the path to the ".pfx" file we want to use for the signature and the password to access this file. We have then included three optional properties. The SigningContact adds an email or contact information to the signature metadata, SigningLocation represents the location where the document is signed, and SigningReason provides the reason for the document being signed.

Next, we need to sign the PDF document with the PdfSignature object we created. By calling the Sign method, we are able to apply the signature to the PDF document in one easy line. Multiple signing certificates may be applied to the PDF document using this method.

Finally, we will save the signed PDF document using the SaveAs method, which saves the PDF to the specified file location.

Click here to view the How-to Guide, including examples, sample code, and files >