Some test text!

Discord Logo

Chat with us

PDFTron is now Apryse, learn more here.

Nodejs / Guides / Sign a document


PDFTron is now Apryse, learn more here.

Sign a PDF document in Node.js

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

async function main() {
  const doc = await PDFNet.PDFDoc.createFromFilePath(in_docpath);

  // Retrieve the unsigned approval signature field.
  const found_approval_field = await doc.getField(in_approval_field_name);
  const found_approval_signature_digsig_field = await PDFNet.DigitalSignatureField.createFromField(found_approval_field);

  // (OPTIONAL) Add more information to the signature dictionary.
  await found_approval_signature_digsig_field.setLocation('Vancouver, BC');
  await found_approval_signature_digsig_field.setReason('Document certification.');
  await found_approval_signature_digsig_field.setContactInfo('');

  // (OPTIONAL) Add an appearance to the signature field.
  const img = await PDFNet.Image.createFromFile(doc, in_appearance_img_path);
  const found_approval_signature_widget = await PDFNet.SignatureWidget.createFromObj(await found_approval_field.getSDFObj());
  await found_approval_signature_widget.createSignatureAppearance(img);

  // Prepare the signature and signature handler for signing.
  await found_approval_signature_digsig_field.signOnNextSave(in_private_key_file_path, in_keyfile_password);

  // The actual approval signing will be done during the following incremental save operation.
  await, PDFNet.SDFDoc.SaveOptions.e_incremental);

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

About Adding An Approval Signature to a PDF Document

The Apryse SDK enables approval signatures in PDF documents using a Digital Certificate, in accordance with the latest PDF specification. By leveraging public key infrastructure (PKI) technology, with a certificate issued by a trusted certificate authority (CA), a signer can use a certificate-based digital ID to guarantee the authenticity of a signature. Placement of a digital signature using a certificate can also guarantee that a document was not modified since the signature was placed, ensuring the authenticity of the document.

Image taken from Apryse WebViewer

Above is an example of a document containing a certified signature, guaranteed by a certificate generated by

Get the answers you need: Support