-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.vb
40 lines (32 loc) · 1.33 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
37
38
39
40
Imports DevExpress.Pdf
Imports DevExpress.Office.Tsp
Imports DevExpress.Office.DigitalSignatures
Imports System
Imports System.Diagnostics
Namespace CustomSigner
Friend NotInheritable Class Program
Private Sub New()
End Sub
Shared Sub Main(ByVal args() As String)
Using signer = New PdfDocumentSigner("Document.pdf")
'Create a timestamp:
Dim tsaClient As ITsaClient = New TsaClient(New Uri("https://freetsa.org/tsr"), HashAlgorithmType.SHA256)
'Specify the signature's field name and location:
Dim description = New PdfSignatureFieldInfo(1)
description.Name = "SignatureField"
description.SignatureBounds = New PdfRectangle(10, 10, 50, 150)
'Create a custom signer object:
Dim bouncyCastleSigner = New BouncyCastleSigner("certificate.pfx", "123", tsaClient)
'Apply a signature to a new form field:
Dim signatureBuilder = New PdfSignatureBuilder(bouncyCastleSigner, description)
'Specify the image and signer information:
signatureBuilder.SetImageData(System.IO.File.ReadAllBytes("signature.jpg"))
signatureBuilder.Location = "LOCATION"
'Sign and save the document:
signer.SaveDocument("SignedDocument.pdf", signatureBuilder)
Process.Start(New ProcessStartInfo("SignedDocument.pdf") With {.UseShellExecute = True})
End Using
Return
End Sub
End Class
End Namespace