ActiveReports 6 Online Help
Create a Digital Signature for a PDF Export
See Also Send comments on this topic.
ActiveReports 6 > ActiveReports User Guide > How To > Export Reports > Create a Digital Signature for a PDF Export

Glossary Item Box

This feature is for use with the Professional Edition license only. An evaluation message is rendered when used with the Standard Edition license.

Important: In order to create a digital signature, you must first have a valid PKCS#12 certificate (*.pfx) file.

To use the code below, change the path and file name to point to your PFX, and change "password" to the password for your PFX file. You can use a third-party digital ID, or create a self-signed certificate.

For information on creating a self-signed certificate, see the Adobe Acrobat Help topic "Create a self-signed digital ID."

You can also create a PFX file from the Visual Studio command line. For more information and links to SDK downloads, see http://www.source-code.biz/snippets/vbasic/3.htm.


The following code samples assume that you have a report variable rpt, and that you have dragged the PDFExport object onto your form.

To add an invisible signature

The following example shows what the code for adding an invisible signature looks like. Replace the path and filename and password of the Certificate with your certificate information.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Invisible
' Set certificate & password.
Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Application.StartupPath & "\..\..\certificate.pfx", "password") 

' Signature items. 
Me.PdfExport1.Signature.Reason = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("I agree.") 
Me.PdfExport1.Signature.Location = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("Japan")

Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\VisibilityType_Invisible.pdf")

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
String path = Path.Combine(Application.StartupPath, "\..\..\certificate.pfx");

String output = “output.pdf”;
// Set certificate & password.
this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(path, "password");

// Signature items.
this.pdfExport1.Signature.Reason = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField <String>("I agree."); 
this.pdfExport1.Signature.Location = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField <String>("Japan");

this.pdfExport1.Export(rpt.Document, output);

To add a visible signature with the time stamp

The following example shows what the code for adding a visible signature with the time stamp looks like.  Replace the path and filename and password of the Certificate with your certificate information, and replace the time stamping authority (TSA) URL with that of your TSA.

Note: You must purchase a volume-based registration at an actual TSA for your applications.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
' Text signature.
Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Text
Me.PdfExport1.Signature.Stamp.Bounds = New RectangleF(1, 1, 4, 2)
Me.PdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Left

' Set certificate & password.
Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Application.StartupPath & "\..\..\certificate.pfx", "password")

' Signature items.
Me.PdfExport1.Signature.SignDate = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of Date)(System.DateTime.Now(), True)
Me.PdfExport1.Signature.Contact = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("ar6@grapecity.com", True)
Me.PdfExport1.Signature.Reason = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("I agree.", True)
Me.PdfExport1.Signature.Location = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("Japan", True)

' Time stamp.
Me.PdfExport1.Signature.TimeStamp = New DataDynamics.ActiveReports.Export.Pdf.Signing.TimeStamp("http://TSAServer", "null", "null")
Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\TimeStamped.pdf")

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
// Text signature.
this.pdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Text;
this.pdfExport1.Signature.Stamp.Bounds = new RectangleF(1, 2, 5, 2);
this.pdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Left;

// Set certificate & password.
this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(Application.StartupPath & "\..\..\certificate.pfx", "password");

// Signature items.
this.pdfExport1.Signature.SignDate = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<System.DateTime>(System.DateTime.Now, true);
this.pdfExport1.Signature.Contact = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<String>("ar6@grapecity.com", true);
this.pdfExport1.Signature.Reason = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<String>("I agree.", true);
this.pdfExport1.Signature.Location = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<String>("Japan", true);

// Time stamp.
this.pdfExport1.Signature.TimeStamp = new DataDynamics.ActiveReports.Export.Pdf.Signing.TimeStamp("http://TSAServer", "null", "null");

this.pdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\TimeStamped.pdf");

To add a visible signature with text and graphics elements

The following example shows what the code for adding a visible signature with text and graphics looks like.  Replace the path and filename and password of the Certificate with your certificate information.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
' ImageText signature.
Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.ImageText

' Bounds (Container of Text & Image).
Me.PdfExport1.Signature.Stamp.Bounds = New RectangleF(2, 1, 5, 1)

' Text area.
Me.PdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Left
Me.PdfExport1.Signature.Stamp.Font = New Font(System.Drawing.FontFamily.GenericSansSerif, 8, FontStyle.Regular)
' Note: Specify (x, y) in relative coordinate from Bounds top-left.
Me.PdfExport1.Signature.Stamp.TextRectangle = New RectangleF(2, 0, 3, 1)

' Image area.
Me.PdfExport1.Signature.Stamp.Image = Image.FromFile(Application.StartupPath & "\..\..\image\stamp.bmp")
Me.PdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Center
' Note: Specify (x, y) in relative coordinate from Bounds top-left.
Me.PdfExport1.Signature.Stamp.ImageRectangle = New RectangleF(0, 0, 2, 1)

' Set certificate & password.
Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Application.StartupPath & "\..\..\certificate.pfx", "password")

' Signature items.
Me.PdfExport1.Signature.SignDate = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of Date)(System.DateTime.Now(), True)
Me.PdfExport1.Signature.Contact = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("ar6@grapecity.com", True)
Me.PdfExport1.Signature.Reason = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("I agree.", True)
Me.PdfExport1.Signature.Location = New DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField(Of String)("Japan", True)

Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\TextAndGraphics.pdf")

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
// ImageText signature.
this.pdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.ImageText;

// Bounds (Container of Text & Image).
this.pdfExport1.Signature.Stamp.Bounds = new RectangleF(2, 1, 5, 1);

// Text area.
this.pdfExport1.Signature.Stamp.TextAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Left;
this.pdfExport1.Signature.Stamp.Font = new Font("Comic Sans MS", 8, FontStyle.Regular);
// Note: Specify (x, y) in relative coordinate from Bounds top-left.
this.pdfExport1.Signature.Stamp.TextRectangle = new RectangleF(2, 0, 3, 1);

// Image area.
this.pdfExport1.Signature.Stamp.Image = Image.FromFile("stamp.bmp");
this.pdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Center;
// Note: Specify (x, y) in relative coordinate from Bounds top-left.
this.pdfExport1.Signature.Stamp.ImageRectangle = new RectangleF(0, 0, 2, 1);

// Set certificate & password.
this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("c:\\certificate.pfx", "password");

//Signature items.
this.pdfExport1.Signature.SignDate = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<System.DateTime>(System.DateTime.Now, true);
this.pdfExport1.Signature.Contact = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<string>("ar6@grapecity.com", true);
this.pdfExport1.Signature.Reason = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<string>("I agree.", true);
this.pdfExport1.Signature.Location = new DataDynamics.ActiveReports.Export.Pdf.Signing.SignatureField<string>("Japan", true);

this.pdfExport1.Export(rpt.Document, "c:\\TextAndGraphics.pdf");

To add a visible signature with graphics

The following example shows what the code for adding a visible signature with graphics looks like. Replace the path and filename and password of the Certificate with your certificate information.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
' Image signature.
Me.PdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Image
Me.PdfExport1.Signature.Stamp.Image = Image.FromFile(Application.StartupPath & "\..\..\image\stamp.bmp")
Me.PdfExport1.Signature.Stamp.Bounds = New RectangleF(1, 2, 4, 1)
Me.PdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Left

' Set certificate & password.
Me.PdfExport1.Signature.Certificate = New Security.Cryptography.X509Certificates.X509Certificate2(Application.StartupPath & "\..\..\certificate.pfx", "password")

Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\VisibilityType_Image.pdf")

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
// Image signature.
this.pdfExport1.Signature.VisibilityType = DataDynamics.ActiveReports.Export.Pdf.Signing.VisibilityType.Image;
this.pdfExport1.Signature.Stamp.Image = Image.FromFile("c:\\stamp.bmp");
this.pdfExport1.Signature.Stamp.Bounds = new RectangleF(1, 2, 4, 1);
this.pdfExport1.Signature.Stamp.ImageAlignment = DataDynamics.ActiveReports.Export.Pdf.Signing.Alignment.Left;

// Set certificate & password.
this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("c:\\certificate.pfx", "password");

this.pdfExport1.Export(rpt.Document, "c:\\VisibilityType_Image.pdf");

To add a certifying signature

The following example shows what the code for adding a certifying signature with form filling permission looks like. Replace the path and filename and password of the Certificate with your certificate information.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the Form Load event. Copy Code
Me.PdfExport1.Signature.Certificate = New System.Security.Cryptography.X509Certificates.X509Certificate2(Application.StartupPath & "\..\..\certificate.pfx", "password")
Me.PdfExport1.Signature.CertificationLevel = DataDynamics.ActiveReports.Export.Pdf.Signing.CertificationLevel.FormFilling
Me.PdfExport1.Export(rpt.Document, Application.StartupPath & "\..\..\Certified_FormFilling.pdf")

ShowTo write the code in C#

C# code. Paste INSIDE the Form Load event. Copy Code
this.pdfExport1.Signature.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("c:\\certificate.pfx", "password");
this.pdfExport1.Signature.CertificationLevel = DataDynamics.ActiveReports.Export.Pdf.Signing.CertificationLevel.FormFilling;
this.pdfExport1.Export(rpt.Document, "c:\\Certified_FormFilling.pdf");

See Also