Article : Create a Digital Signature for a PDF Export
Create a Digital Signature for a PDF Export
See Also
ActiveReports 6 > ActiveReports User Guide > How To > Export Reports > Create a Digital Signature for a PDF Export
Show AllShow All
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.
Click to EnlargeClick to Enlarge
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#
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#
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
ShowTo write the code in C#
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
ShowTo write the code in C#
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")