PDFtoolkit VCL
Edit, enhance, secure, merge, split, view, print PDF and AcroForms documents
Delphi C++Builder

How To Digitally Sign A PDF Document In Delphi

Learn to add a signature form field to a PDF document.
By V. Subhash

In September 2009, we introduced the ability to digitally sign PDF documents in PDFtoolkit.

In a PDF document, digital signatures are represented as signature form fields. Signature form fields can be either visible or invisible. Visible signature fields are usually accompanied by the scanned image of a signature of a real person and/or the seal of an organization.

When the requirement is simply to sign a PDF document, then a hidden signature field would be enough. A viewer application such as Adobe Reader would still be able to identify and validate the signature in the document. In this article, we will see a code example on how to create such a document.

The method to add a signature is TgtPDFDocument.AddSignature(). It has several overloads for this method. In the following code example, the overload requires:

  1. PFXFileName: AnsiString - Pathname of the PFX file containing the digital certificate. You will get this file from a Certification Authority (CA).
  2. PFXPassword: AnsiString - Password for the PFX file.
  3. Reason: AnsiString Text that needs to be identified as the "reason" for adding the digital signature. For example, you can specify it as "I agree."
  4. Location: AnsiString - Text that needs to be identified as the "location" where the digital signature was added to the document. For example, you can use the CPU host name or the physical address where the signature was added.
  5. ContactInfo: AnsiString - Text that needs to be identified as the "contact information" of the owner of the digital signature. This information can be useful for the recipient of the document to contact the owner of the signature.
  6. PageNumber: Integer - Number of the page where the digital signature is added.
  7. FieldName: AnsiString - Name for the signature form field representing the digital signature. If a name is not specified, the PDF document component will generate a name for it.
program TgtPDFDocument_AddSignature_Hidden;


  gtPDFDoc, gtExPDFDoc;

  gtPDFDocument1: TgtPDFDocument;
  // Create a document object
  gtPDFDocument1 := TgtPDFDocument.Create(Nil);


    // Load input document
    Writeln('Document opened.');

    // Add a hidden signature field to a page
        '-- snipped --',
        'To demonstrate digital signing',
    Writeln('Document signed.');

    Writeln('Document saved.');

  except on Err:Exception do
     Writeln('Sorry, an exception was raised. ');
     Writeln(Err.Classname + ':' + Err.Message);

  // Free resources

  // Destroy document object

  Writeln('Press Enter to exit.');


Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.


A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2018 Gnostice Information Technologies Private Limited. All rights reserved.