xtrareports-devexpress-dot-xtrareports-dot-ui-e31b4e3d.md
Adds a visual signature to a report exported to PDF.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public class XRPdfSignature :
XRControl
Public Class XRPdfSignature
Inherits XRControl
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.
Drop the XRPdfSignature control from the Toolbox onto a report.
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.
Expand the control’s smart tag and enable check boxes for the signature fields that you want to display.
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 |
|---|---|
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 = "[email protected]";
report.ExportToPdf("ReportWithSignature.pdf");
' Create a simple report.
Dim report = New XtraReport()
Dim band = New DetailBand()
Dim control = New XRPdfSignature()
With control.SignatureOptions
.ImageDisplayMode = SignatureImageDisplayMode.Show
.ShowCaptions = False
.ShowCertificateName = True
.ShowDistinguishedName = False
.ShowLocation = True
.ShowSignatureDate = True
.ShowSignatureReason = True
End With
band.Controls.Add(control)
report.Bands.Add(band)
' Specify signature information.
Dim certificate As New X509Certificate2("Data\AndrewFuller.pfx", "AndrewFullerPassword")
With report.ExportOptions.Pdf.SignatureOptions
.Certificate = certificate
.ImageSource = ImageSource.FromFile("Images\signature.png")
.Reason = "Approved"
.Location = "USA"
.ContactInfo = "[email protected]"
End With
report.ExportToPdf("ReportWithSignature.pdf")
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 UIImplement 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 documentOverride the CustomizeExportDocumentOnFinish method to retrieve and sign the exported document.
The following example shows how to sign a document exported to PDF:
View Example: How to Sign the Exported PDF Document
Object MarshalByRefObject Component XRControl XRPdfSignature
See Also