Example E4191
Visible to All Users

Reporting for WinForms - Apply a Digital Signature When Exporting a Report to PDF

This example shows how to apply a digital signature when a report is exported to PDF using the XtraReport.ExportOptions.Pdf.SignatureOptions property.

The code uses the X509Store class as a local storage for digital certificates.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

pdf-signature-sample/Form1.cs(vb)
C#
#region #usings using System; using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; // ... #endregion #usings namespace pdf_signature_sample { public partial class Form1 : Form { public Form1() { InitializeComponent(); } #region #export private void Export() { XtraReport1 report = new XtraReport1(); // Create a new X509Certificate2 object. X509Certificate2 certificate = new X509Certificate2(); // Initialize a local certificate storage and define its options. X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); // Initialize a certificate collection and adjust its work. X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates; X509Certificate2Collection fcollection = (X509Certificate2Collection)collection.Find(X509FindType.FindByTimeValid, DateTime.Now, true); X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Test Certificate Select", "Select a certificate from the following list to get information on that certificate", X509SelectionFlag.SingleSelection); if(scollection.Count > 0) certificate = scollection[0]; // Define the remaining PDF signature options. report.ExportOptions.Pdf.SignatureOptions.ContactInfo = "contact info"; report.ExportOptions.Pdf.SignatureOptions.Location = "location"; report.ExportOptions.Pdf.SignatureOptions.Reason = "reason"; // Assign the created certificate to the signature options of the PDF export options. report.ExportOptions.Pdf.SignatureOptions.Certificate = certificate; // Export the report to a PDF file // created in the same folder where the application's .exe file is located. report.ExportToPdf("test.pdf"); System.Diagnostics.Process.Start("test.pdf"); } #endregion #export private void button1_Click(object sender, EventArgs e) { Export(); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.