Digital Certifying
Digitally certify a document either visually or invisible. Examples of both ways of certifying a document are presented here.
Certificate
Both visible and invisible certification use the Certificate class which represents a digital certificate.
Properties
Property | Description |
---|---|
IncludeWholeChain | Specifies how much of the X.509 certificate chain should be included in the signed data. Default value is True . If it is False , the include option will be EndCertOnly . |
Issuer | Gets the complete issuer string from the certificate loaded. |
SignatureType | Gets or sets type of signature. |
SignSilently | Gets or sets to prompt for the selection of a signing certificate. |
Subject | Gets the complete subject string from the certificate loaded. |
SubjectName | Gets the subject name of the certificate loaded. |
TimestampServerUrl | Get the Timestamp Server Url from the certificate loaded. |
When certifying a document - both visible and invisible - use the Document class's Certify method. This method has four overloads.
Certify Method | Description |
---|---|
Certify(String, Certificate, Boolean, CertifyingPermission) | Certifies with signing and Time stamping the document digitally. |
Certify(String, Certificate, CertifyingPermission) | Certifies with signing the document digitally. |
Certify(String, Certificate, TimestampServer, CertifyingPermission) | Certifies with signing and Time stamping the document digitally. |
Certify(String, SigningProvider, CertifyingPermission) | Certifies with signing and Time stamp. |
Visible Digital Certification
Digitally certifying a PDF establishes that a document will not be changed in any way except for limited edits specified by the digital ID owner (i.e., form filling and commenting). Also similar to digital signatures, digital certificates can either be a visible part of the PDF document (using a defined Signature Field) or be noted as part of the document's properties and not visible from the PDF page's content.
To add certification as visible fields in the document, you must first create and add a SignatureField to the 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, call the Document object's Certify method passing in the name of the Signature field, the Certificate object, and the CertifyingPermission (this specifies whether any changes such as form filling or comments are 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)
Refer to the Certificate API documentation for a complete example.
Invisible Digital Certification
Digital certifications can be added so that they are part of the document but not viewable from any of the pages. To accomplish this, omit the creation of the Signature field from the above example. The Document instance's Sign method specifies a string that does not match the name of any form fields on the document. If the field name passed into the Sign method matches a field but is a non-signature field, then the document is 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)