Some test text!

menu
Sign a documentkeyboard_arrow_down

Sign a PDF document in C++

To sign an existing approval signature field in a PDF Document:

// Open an existing PDF
PDFDoc doc(docpath);

// Retrieve the unsigned approval signature field.
Field found_approval_field(doc.GetField(approval_field_name));
PDF::DigitalSignatureField approval_digsig_field(found_approval_field);

// (OPTIONAL) Add more information to the signature dictionary.
approval_digsig_field.SetLocation("Vancouver, BC");
approval_digsig_field.SetReason("Document approval.");
approval_digsig_field.SetContactInfo("www.pdftron.com");

// (OPTIONAL) Add an appearance to the signature field.
PDF::Image img = PDF::Image::Create(doc, appearance_img_path);
Annots::SignatureWidget approval_signature_widget(found_approval_field.GetSDFObj());
approval_signature_widget.CreateSignatureAppearance(img);

// Prepare the signature and signature handler for signing.
approval_digsig_field.SignOnNextSave(private_key_file_path, keyfile_password);

// The actual approval signing will be done during the following incremental save operation.
doc.Save(outpath, SDFDoc::e_incremental, NULL);

Digitally sign 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

close

Free Trial

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.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close