eDocEngine VCL
Create documents and reports in 18 formats
Delphi C++Builder

Generating Digitally Signed PDF Documents In Delphi

Learn to use eDocEngine VCL to create PDFs with hidden and visible digital signatures.
By Manikanta Sai Prasad

In Version 4, we introduced support for adding digital signatures in the PDF engine. The code for generating PDFs with digital signatures is simple.

First, create a TgtDigitalSignature instance and then set it to the DigitalSignature property of the PDF engine. When the PDF is generated, it would have been signed.

There are two types of signatures that can be added to a PDF - visible and hidden.

Hidden Signatures

First, let us see how a hidden signature is created. To include a digital signature, you need to have the digital certificate in a PFX file. TgtDigitalSignature instance has two important properties. One is the FieldProperties property. This is where you specify the signature form field properties. As we first create a hidden signature, we just set its Visible property to false. SignatureProperties property of the DigitalSignature is where you specify the pathname of the PFX file, its password and other signature properties such as reason, location and timestamp.

program Digital_Signature_Demo;


{$R *.res}

  System.SysUtils, VCL.Graphics,
  gtPDFEng, gtCstPDFEng;

  gtPDFEngine1: TgtPDFEngine;
  tNow: TDateTime;
  gtDigitalSignature1: TgtDigitalSignature;
  try begin
    // Create a new PDF document
    gtPDFEngine1 := TgtPDFEngine.Create(Nil);

    with gtPDFEngine1 do begin
      Preferences.ShowSetupDialog := false;
      FileName := 'sample_doc.pdf';
      // Create a hidden digital signature
      with DigitalSignature do begin
        Enabled := true;
        FieldProperties.Visible := false;  // hidden signature
        // Specify signature options
        with SignatureProperties do begin
          CertFileName := 'example-com.pfx'; // assumes current directory
          CertPassword := 'password';
          Location := 'Bangalore';
          Reason := 'Just for this demo';
          DateTime := Now;

      BeginDoc;  // Creates a page in the document
        // Render some text on the document
        Font.Size := 16;
        TextOut(1,1,'Long long ago, so long ago, nobody knows how long ago...');
      EndDoc;   // Saves document
    except on E: Exception do begin
      Writeln('Error - ' + E.ClassName, ': ', E.Message);

Visible PDF Signature

To create a visible signature, just set the Visible property to true and set FieldBounds property to the location where the signature field needs to appear.


FieldProperties.Visible := true;   // visible signature        

with FieldProperties.FieldBounds do begin
  FLLeft := 2;
  FLTop := 2;



Our .NET Developer Tools
Gnostice Document Studio .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
Gnostice Document Studio 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-2019 Gnostice Information Technologies Private Limited. All rights reserved.