Digital Certifying

Digitally certify a document either visually or invisible. The following two topics discuss this distinction.

Visible Digital Certification

In much the same way that PDF documents can be digitally signed (as was demonstrated above) they can also be certified. Digitally certifying a PDF establishes that a document will not be changed in anyway except a limited edits that the owner of the digital ID can specify (namely form filling and commenting). Also similar to digital signatures, digital certificates can either be a visual part of the PDF document (using a defined Signature Field) or it can be just noted as part of the documents properties and not visible from the PDF pages content.

To add a certification as visible fields in the document you must first create and add a Signature Field to a Page (this defines where the certificate will be visible on that page). Then create a Certificate object (based on the personal information exchange file or PFX and the password). Finally you must call the Document object's Certify method passing in the name of the Signature Field, the Certificate object as well as a CertifyingPermission (this specifies whether any changes such as form filling or comments will be allowed).

The following example demonstrates adding a visible digital certification 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.Certiry("SigField", certificate, CertifyingPermission.NoChangesAllowed);
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.Certify("SigField", MyCertificate, CertifyingPermission.NoChangesAllowed)
MyDocument.Draw(pdfFilePath)   

Invisible Digital Certification

Alternatively, digital certifications can be added so that they are part of the Document but not actually viewable from any of the pages. To accomplish this just omit the creating of the Signature Field from the above example. In the Document's Sign method make sure to specify a string that does not match the name of any form fields on the document. If the field name passed into the Document's Sign method does match a field but it is a non-signature field then the document will be left unsigned. A document should only be certified once.

The following example demonstrates adding an invisible digital certification 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.Certify("NonExistingField", certificate. CertifyingPermission.NoChangesAllowed);
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.Certify("NonExistingField", MyCertificate, CertifyingPermission.NoChangesAllowed)
MyDocument.Draw(pdfFilePath)

In this topic