xtrareports-devexpress-dot-xtrareports-dot-web-dot-webdocumentviewer-fea13874.md
When implemented, provides asynchronous access to digital signatures in the Web Document Viewer.
Namespace : DevExpress.XtraReports.Web.WebDocumentViewer
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public interface IPdfSignatureOptionsProviderAsync
Public Interface IPdfSignatureOptionsProviderAsync
In MVC and Web Forms applications, use a synchronous approach to get a dictionary of available signatures. If you use asynchronous code to get the signatures, pass false to the ConfigureAwait method throughout the entire chain of methods:
public async Task<Dictionary<string, PdfSignatureOptions>> GetAvailableOptionsAsync() {
var signatures = await GetMySignaturesAsync(...).ConfigureAwait(false);
return signatures;
}
Public Async Function GetAvailableOptionsAsync() As Task(Of Dictionary(Of String, PdfSignatureOptions))
Dim signatures = Await GetMySignaturesAsync(...).ConfigureAwait(False)
Return signatures
End Function
The following example shows how to sign a document exported to PDF from the Web Document Viewer’s UI:
View Example: How to Sign the Exported PDF Document
Implement the IPdfSignatureOptionsProviderAsync interface to register signatures. The GetAvailableOptionsAsync() method returns a dictionary of value pairs: signature certificate identifiers and PdfSignatureOptions objects:
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.Web.WebDocumentViewer;
using Microsoft.AspNetCore.Hosting;
namespace SignPdfDocumentExample.Services {
public class CustomPdfSignatureOptionsProviderAsync : IPdfSignatureOptionsProviderAsync {
readonly Dictionary<string, PdfSignatureOptions> signatures = new Dictionary<string, PdfSignatureOptions>();
public CustomPdfSignatureOptionsProviderAsync(IWebHostEnvironment webHostEnvironment) {
var signatureDictionaryPath = Path.Join(webHostEnvironment.ContentRootPath, "Signatures");
signatures.Add(Guid.NewGuid().ToString(), new PdfSignatureOptions() {
Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(Path.Combine(signatureDictionaryPath, "certificate.pfx"), "123"),
ContactInfo = "Jane Cooper",
});
signatures.Add(Guid.NewGuid().ToString(), new PdfSignatureOptions() {
Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(Path.Combine(signatureDictionaryPath, "certificate.pfx"), "123"),
ContactInfo = "John Smith",
Location = "Australia",
Reason = "I Agree",
ImageSource = DevExpress.XtraPrinting.Drawing.ImageSource.FromFile(Path.Combine(signatureDictionaryPath, "John_Smith.png"))
});
}
public Task<Dictionary<string, PdfSignatureOptions>> GetAvailableOptionsAsync() {
return Task.FromResult(signatures);
}
}
}
To sign a report, select a signature from the drop-down list in PDF Export Options :
During export to PDF, XRPdfSignature is converted to a signature with the specified settings:
See Also