Digitally Sign an existing PDF

To be able to use our DLL to digitally sign a PDF you need to register it first with regasm. The commandline would be:

regasm /codebase Aloaha_ZUGFeRD.dll

After that you can reference the library in VB.NET

Dim pdf As Aloaha_ZUGFeRD.XML
Dim InputPDF As String
Dim SignedPDF As String
Dim CertificateSerialNumber As String
Dim LicenseKey As String
Dim SignatureHashType As Long
Dim SignReason As String
Dim SignContact As String
Dim SignLocation As String
Dim SignImagePath As String
Dim SignPositionLeft As Double
Dim SignPositionTop As Double
Dim SignPositionWidth As Double
Dim SignPositionHeight As Double
Dim SignPage As Long
Dim InputPDFPassword As String
Dim DoOverwrite As Boolean
Dim TSAURL As String
Dim LastError As String
Dim DoCAdES As Boolean
Dim IncludeCRL As Boolean
Dim CertEmailAddress As String

Set pdf = New Aloaha_ZUGFeRD.XML
InputPDF = “D:\pdf\input.pdf”
SignedPDF = “D:\pdf\signed.pdf”
SignImagePath = “D:\pdf\aloaha_square.png”
CertificateSerialNumber = “3b a8 f3 9c 00 00 00 00 28 f6”
LicenseKey = “EFMUJPYCPGT7A7PBYTGBPUP7E4”  ‘This key is valid till the 15th of August
SignReason = “I have seen this document”
SignLocation = “Pembroke/Malta”
DoOverwrite = True
IncludeCRL = True
DoCAdES = True
SignPage = 1
SignPositionWidth = 100
SignPositionHeight = 50
SignPositionLeft = 50
SignPositionTop = 400

SignatureHashType = 2 ‘for SHA 256
If pdf.SignPDF(InputPDF, LicenseKey, CertificateSerialNumber, _
SignatureHashType, SignReason, CertificateSerialNumber, SignLocation, SignedPDF, _
SignImagePath, SignPositionLeft, SignPositionTop, SignPositionWidth, SignPositionHeight, _
SignPage, InputPDFPassword, DoOverwrite, TSAURL, 30000, False, False, True, LastError, _
DoCAdES, IncludeCRL, “”, CertEmailAddress) = True Then

MsgBox CertEmailAddress

else

MsgBox LastError
End If

Please note that we created a complete sample vb.net project. You can download it from:

http://www.aloaha.com/download/sigtest.zip

Once you loaded the sample project make sure that you:

  1. Register the file Aloaha_ZUGFeRD.dll with regasm /codebase <Path to Aloaha_ZUGFeRD.dll>
  2. Update the license key in the source code. You can always request a sample license from info@aloaha.com
  3. Debugging works only in X86. The final project can be compiled as X86, X64 or ANY.