-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomPdfSignatureOptionsProviderAsync.cs
31 lines (29 loc) · 1.65 KB
/
CustomPdfSignatureOptionsProviderAsync.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
}
}
}