XRPdfSignature Class
Adds a visual signature to a report exported to PDF.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Remarks
You can sign a report document when you export it to PDF. The signature information you specify is saved to the document’s PDF Signature Options. The XRPdfSignature control visualizes the document signature information:
Tip
For more information on how to create, export, and sign a report, refer to the following tutorial: Create a Report with a Visual PDF Signature in the Visual Studio Report Designer.
Add a Signature Control to a Report
Drop the XRPdfSignature control from the Toolbox onto a report.
Report with Multiple Signatures
The first XRPdfSignature control is added to a report with the Display Document Signature property enabled. This control visualizes the document signature information.
Other XRPdfSignature controls are added with the Display Document Signature property disabled. When a report is exported to PDF, these controls are converted to signature form fields. Users can open an exported file in a PDF editor and put their signatures in these fields.
Enable a control’s Display Document Signature property to make it visualize the document’s signature information. This property becomes disabled for all other signature controls.
If all signature controls have the Display Document Signature property disabled, the signature information is added to an exported file but is not displayed.
Specify Signature Options
Expand the control’s smart tag and enable check boxes for the signature fields that you want to display.
-
Specifies whether the control shows the signature image. The following property values are available:
Show
The control shows a sample signature image. If an exported document is signed, the converted PDF form field shows the actual signature image.
Hide
The control does not show a signature image.
ShowCertificateNameAsImage
The control shows a sample certificate name in place of a signature image. When an exported document is signed, the converted PDF form field shows the actual certificate name.
-
Specifies whether the control displays the document signature information. For more information, refer to the following section: Report with Multiple Signatures.
The signature control shows the certificate name, distinguished name, location, signature date, and signature reason. Disable the corresponding options in the control’s smart tag to hide these fields.
Disable the Show Captions property to exclude captions from the fields listed above.
Show Captions Enabled | Show Captions Disabled |
---|---|
Limitation
- The XRPdfSignature control is not exported to non-PDF formats. A placeholder is added to exported documents instead.
Display a Signature at Runtime
The following code sample demonstrates how to create a report with an XRPdfSignature control and make this control display the document signature information when a report is exported to PDF.
// Create a simple report.
XtraReport report = new XtraReport()
{
Bands = {new DetailBand() {
Controls = {
new XRPdfSignature() {
SignatureOptions = {
ImageDisplayMode = SignatureImageDisplayMode.Show,
ShowCaptions = false,
ShowCertificateName = true,
ShowDistinguishedName = false,
ShowLocation = true,
ShowSignatureDate = true,
ShowSignatureReason = true
}
}
}
}
}
};
// Specify signature information.
PdfSignatureOptions signatureOptions = report.ExportOptions.Pdf.SignatureOptions;
X509Certificate2 certificate = new X509Certificate2(@"Data\AndrewFuller.pfx", "AndrewFullerPassword");
signatureOptions.Certificate = certificate;
signatureOptions.ImageSource = ImageSource.FromFile(@"Images\signature.png");
signatureOptions.Reason = "Approved";
signatureOptions.Location = "USA";
signatureOptions.ContactInfo = "andrew.fuller@example.com";
report.ExportToPdf("ReportWithSignature.pdf");
Sign the Document on the Web
To sign the exported PDF document in the Web Document Viewer, use one of the following options:
- Sign the document in the Web Document Viewer’s UI
- Implement the IPdfSignatureOptionsProviderAsync interface to register available signature options. Select a signature from the Signature drop-down list in the Export to PDF section.
- Customize the exported document
- Override the CustomizeExportDocumentOnFinish method to retrieve and sign the exported document.
The following example shows how to sign a document exported to PDF: