Skip to content

DevExpress-Examples/reporting-asp-net-core-sign-pdf-on-export

Repository files navigation

Reporting for ASP.NET Core - Use the Web Document Viewer to Sign an Exported PDF Document

This example demonstrates how to sign an exported PDF document.

Add Signature Capabilities to the Document Viewer's UI

File: CustomPdfSignatureOptionsProviderAsync.cs

To pass a collection of signatures to the Web Document Viewer, implement the IPdfSignatureOptionsProviderAsync interface.

In this example, the CustomPdfSignatureOptionsProviderAsync class implements the IPdfSignatureOptionsProviderAsync interface. The GetAvailableOptionsAsync method returns the dictionary of signature identifiers and PdfSignatureOptions objects. This dictionary defines signatures available in the Web Document Viewer.

Select a signature to sign the exported document from the Signature drop down list in the PDF Export Options section:

Signature Options

The selected signature is used to digitally sign the exported PDF document. The XRPdfSignature control adds a visual signature:

Signed PDF Document

Customize the Exported Document

File: CustomViewerOperationLogger.cs

The example uses the PDF Document API to add a digital signature to a PDF document. Override the CustomizeExportDocumentOnFinish method to retrieve and modify the exported document.

Note: If you use this method to sign a PDF document, the XRPdfSignature control doesn't add a visual signature representation. To confirm that the document is signed, open it in the PDF editor.

The CustomViewerOperationLogger service inherits the WebDocumentViewerOperationLogger class. The CustomizeExportDocumentOnFinish method creates a PKCS#7 signature with a certificate and a password specified in the object constructor. PdfSignatureBuilder properties allow you to specify the signer’s name, location, contact information, and the reason for signing.

To sign the exported document, call the PdfDocumentSigner.SaveDocument method and pass the created PdfSignatureBuilder object as a parameter.

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)