Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
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.
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; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, VCL.Graphics, gtPDFEng, gtCstPDFEng; var gtPDFEngine1: TgtPDFEngine; tNow: TDateTime; gtDigitalSignature1: TgtDigitalSignature; begin 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; end; end; 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 end; end except on E: Exception do begin Writeln('Error - ' + E.ClassName, ': ', E.Message); Readln; end; end; end.
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;
end;
...
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .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 DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-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 | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |