-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.vb
36 lines (29 loc) · 1.2 KB
/
Program.vb
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
32
33
34
35
36
Option Infer On
Imports DevExpress.Pdf
Imports DevExpress.Office.DigitalSignatures
Imports DevExpress.Office.Tsp
Imports Org.BouncyCastle.Crypto.Digests
Imports System
Imports System.IO
Imports System.Diagnostics
Namespace CustomTsaClient
Friend Module Program
Sub Main(ByVal args() As String)
Using signer = New PdfDocumentSigner("Document.pdf")
'Create a custom timestamp client instance:
Dim tsaClient As ITsaClient = New BouncyCastleTsaClient(New Uri("https://freetsa.org/tsr"), New Sha256Digest(), New System.Net.Http.HttpClient())
'Create a PKCS#7 signature:
Dim pkcs7Signature As New Pkcs7Signer("testcert.pfx", "123", HashAlgorithmType.SHA256, tsaClient)
'Apply the signature to the form field:
Dim signatureBuilder = New PdfSignatureBuilder(pkcs7Signature, "Sign")
'Specify image data and signer information:
signatureBuilder.SetImageData(File.ReadAllBytes("JaneCooper.jpg"))
signatureBuilder.Location = "United Kingdom"
'Sign and save the document:
signer.SaveDocument("SignedDocument.pdf", signatureBuilder)
End Using
Process.Start(New ProcessStartInfo("SignedDocument.pdf") With {.UseShellExecute = True})
Return
End Sub
End Module
End Namespace