Some test text!

Certify a PDF document

To add a certification signature to a PDF document without a form field.

Unlike, approval signatures, there can be only one certification per PDF document. Only the first signature in the PDF document can be used as the certification signature. Certifying a document is like notarizing a document. The process of certifying a document is almost exactly the same as adding approval signatures with the exception of certification signatures requires an entry in the "Perms" dictionary.

// Open an existing PDF
PDFDoc doc = new PDFDoc(input_path + input_filename);

// Create a new instance of the SignatureHandler.
DotNetCryptoSignatureHandler sigHandler = new DotNetCryptoSignatureHandler(input_path + certfile, "password");

// Add the SignatureHandler instance to PDFDoc, making sure to keep track of it using the ID returned.
SignatureHandlerId sigHandlerId = doc.AddSignatureHandler(sigHandler);

// Create new signature form field in the PDFDoc.
Field sigField = doc.FieldCreate("Signature1", Field.Type.e_signature);
Page page1 = doc.GetPage(1);
Widget widgetAnnot = Widget.Create(doc.GetSDFDoc(), new Rect(0, 0, 0, 0), sigField);
Obj widgetObj = widgetAnnot.GetSDFObj();
widgetObj.PutNumber("F", 132);
widgetObj.PutName("Type", "Annot");

// Tell PDFNet to use the SignatureHandler created to sign the new signature form field.
Obj sigDict = sigField.UseSignatureHandler(sigHandlerId);

// Add more information to the signature dictionary
sigDict.PutName("SubFilter", "adbe.pkcs7.detached");
sigDict.PutString("Name", "PDFTron");
sigDict.PutString("Location", "Vancouver, BC");
sigDict.PutString("Reason", "Document verification.");

// Add this sigDict as DocMDP in Perms dictionary from root
Obj root = doc.GetRoot();
Obj perms = root.PutDict("Perms");

// add the sigDict as DocMDP (indirect) in Perms
perms.Put("DocMDP", sigDict);

// add the additional DocMDP transform params
Obj refObj = sigDict.PutArray("Reference");
Obj transform = refObj.PushBackDict();
transform.PutName("TransformMethod", "DocMDP");
transform.PutName("Type", "SigRef");
Obj transformParams = transform.PutDict("TransformParams");
transformParams.PutNumber("P", 1); // Set permissions as necessary.
transformParams.PutName("Type", "TransformParams");
transformParams.PutName("V", "1.2");

Digitally sign and verify PDF files
Full code sample which demonstrates using the digital signature API to digitally sign and/or certify PDF documents.

Get the answers you need: Support