Digital Signing

A PDF document can have a digital ID applied to it or a digital signature can be added so it is part of the Document. Digital signatures can be visible or invisible, as the following two topics illustrate.

Visible Digital Signatures

Apply a digital ID to a PDF to digitally sign it. Add the digital ID to visually appear on the page of the PDF (through a Signature field). To add signatures as visible fields in the document, first create and add a Signature field to a Page (this defines where the signature will be visible on that page), then create a Certificate object (based on the personal information exchange file or PFX and the password) then finally you must call the Document object's Sign method passing in the name of the Signature field and the Certificate object.

The following example demonstrates adding a visible digital signature to a PDF document.

Document document = new Document();
Page page = new Page();

//Create add Signature Form Field
Signature signature = new Signature("SigField", 10, 10, 250, 100);
page.Elements.Add(signature);
document.Pages.Add(page);
Certificate certificate = new Certificate(@"C:\PersonalFiles\JohnDoe.pfx", "password");

// Field name should be one of the signature field name 
document.Sign("SigField", certificate);
document.Draw(pdfFilePath);        
Dim MyDocument As New Document()
Dim MyPage = New Page()

' Create add Signature Form Field
Dim MySignature As New Signature("SigField", 10, 10, 250, 100)
MyPage.Elements.Add(MySignature)
MyDocument.Pages.Add(MyPage)
Dim MyCertificate As New Certificate("C:\PersonalFiles\JohnDoe.pfx", "password")

' Field name should be one of the signature field name 
MyDocument.Sign("SigField", MyCertificate)
MyDocument.Draw(pdfFilePath)    

Invisible Digital Signatures

To add a signature to a Document that is not viewable from any of the pages simply omit creating a Signature field. In a Document instance's Sign method specify a string that does not match the name of any form fields on the document. If the field name passed into the Document instance's Sign method does match a field but it is a non-signature field, then the document remains unsigned.

A Document instance's Sign method can only be applied once (allowing only one signature to be associated with each document).

The following example demonstrates adding an invisible digital signature to a PDF document.

Document document = new Document();
Page page = new Page();

document.Pages.Add(page);
Certificate certificate = new Certificate(@"C:\PersonalFiles\JohnDoe.pfx", "password");

// Field name should not match any field names in the document 
document.Sign("NonExistingField", certificate);
document.Draw(pdfFilePath);        
Dim MyDocument As New Document()
Dim MyPage = New Page()

MyDocument.Pages.Add(MyPage)
Dim MyCertificate As New Certificate("C:\PersonalFiles\JohnDoe.pfx", "password")

' Field name should not match any field names in the document 
MyDocument.Sign("NonExistingField", MyCertificate)
MyDocument.Draw(pdfFilePath)

In this topic