Some test text!
To add a certification signature field to a PDF document and sign it:
# Open an existing PDF doc = PDFDoc(docpath) page1 = doc.GetPage(1) # Create a text field that we can lock using the field permissions feature. annot1 = TextWidget.Create(doc.GetSDFDoc(), Rect(50, 550, 350, 600), "asdf_test_field") page1.AnnotPushBack(annot1) # Create a new signature form field in the PDFDoc. The name argument is optional; # leaving it empty causes it to be auto-generated. However, you may need the name for later. # Acrobat doesn't show digsigfield in side panel if it's without a widget. Using a # Rect with 0 width and 0 height, or setting the NoPrint/Invisible flags makes it invisible. certification_sig_field = doc.CreateDigitalSignatureField(cert_field_name) widgetAnnot = SignatureWidget.Create(doc, Rect(0, 100, 200, 150), certification_sig_field) page1.AnnotPushBack(widgetAnnot) # (OPTIONAL) Add an appearance to the signature field. img = Image.Create(doc.GetSDFDoc(), appearance_image_path) widgetAnnot.CreateSignatureAppearance(img) # Prepare the document locking permission level to be applied upon document certification. certification_sig_field.SetDocumentPermissions(DigitalSignatureField.e_annotating_formfilling_signing_allowed) # Prepare to lock the text field that we created earlier. certification_sig_field.SetFieldPermissions(DigitalSignatureField.e_include, ['asdf_test_field']) certification_sig_field.CertifyOnNextSave(private_key_file_path, keyfile_password) # (OPTIONAL) Add more information to the signature dictionary. certification_sig_field.SetLocation('Vancouver, BC') certification_sig_field.SetReason('Document certification.') certification_sig_field.SetContactInfo('www.pdftron.com') # Save the PDFDoc. Once the method below is called, PDFNet will also sign the document using the information provided. doc.Save(outpath, 0)
Digitally sign PDF files
Full code sample which demonstrates using the digital signature API to digitally sign and/or certify PDF documents.
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.
Get the answers you need: Support
Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.
Select a platform to get started with your free trial.
Unlimited usage. No email address required.
PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital PartnersLearn more