The Aloaha PDF Signator contains many useful API to automate your tasks. With the right license (contact sales@aloaha.com) you can fill in your PDF Forms, seal them and also digitally sign them.
There are two identical classes you can use. One runs “in process” and one runs “out of process – OOP”.
Just reference the class AloahaSimplePDF.simpleEdit or just directly create it with set pdf=createobject(“AloahaSimplePDF.simpleEdit”).
In case you prefer managed code please use our ZUGFeRD Library:
http://www.zugferdpro.com/pdf-formulare-ausfuellen-und-digital-signieren/
As sample PDF Form we are going to use: “Überweisungsschein für Laboratoriumsuntersuchungen als Auftragsleistung.pdf“: muster10.pdf
Another sample is: “Anforderungsschein für Laboratoriumsuntersuchungen bei Laborgemeinschaften”:
First you need to configure the input and the output PDF:
Call pdf.Set_ZUGFeRD_InputPDF(“d:\pdf2\muster10.pdf”)
Call pdf.Set_ZUGFeRD_OutPutPDF(“d:\pdf2\output.pdf”)
Once you have done that you can already count or list muster10a.pdfthe form fields of the PDF Form:
Dim fcount As Long
fcount = pdf.FormFields
Dim fnames() As String
fnames = pdf.FormFieldNames
Obviously you can also directly write data to the form fields:
Call pdf.WriteData2FormField(“4221_Kurativ”, “1”)
Call pdf.WriteData2FormField(“0000_Titel_Vorname_Namenszusatz_Vorsatzwort”, “John”)
Call pdf.WriteData2FormField(“Name”, “Doe”)
To write data to the XMP Properties use:
Call pdf.WriteData2XMPField(“Anzahl_Zeichen_Titel”, “22”)
Most important for most customer is the digital signature API to seal and sign the PDF Form:
Dim CertSerial As String
Dim DoOverWrite As Boolean
Dim SignPage As Integer
Dim SignatureHashtype As Integer
Dim SignatureImagePath As String
Dim SignatureLeft As Double
Dim SignatureTop As Double
Dim SignatureWidth As Double
Dim SignatureHeight As Double
Dim InputPDFPassword As String
Dim TSAURL As String
Dim signatureLength As Long
Dim SizeIsPercent As Boolean
Dim ForceSettingsGUI As Boolean
Dim StopIfCertNotFound As Boolean
Dim Sign_x509 As Object
Dim LastSignError As String
Dim DoCAdES As Boolean
Dim IncludeCRL As Boolean
Dim PIN As String
Dim Usedx509 As Object
CertSerial = “”
DoOverWrite = True
SignPage = 1
SignatureHashtype = 2
SignatureImagePath = “”
SignatureLeft = 0
SignatureTop = 0
SignatureWidth = 0
SignatureHeight = 0
InputPDFPassword = “”
TSAURL = “”
signatureLength = 30000
SizeIsPercent = False
ForceSettingsGUI = False
StopIfCertNotFound = False
Set Sign_x509 = Nothing
LastSignError = “”
DoCAdES = True
IncludeCRL = True
PIN = “”
Set Usedx509 = Nothing
Call pdf.Set_ZUGFeRD_SignContact(“info@aloaha.com”)
Call pdf.Set_ZUGFeRD_SignLocation(“Pembroke”)
Call pdf.Set_ZUGFeRD_SignReason(“I have seen this document”)
Call pdf.Set_ZUGFeRD_OutPutPDF(“d:\pdf2\signed.pdf”)
Call pdf.ZUGFERDSignAndSave(CertSerial, DoOverWrite, SignPage, SignatureHashtype, _
SignatureImagePath, SignatureLeft, SignatureTop, _
SignatureWidth, SignatureHeight, InputPDFPassword, _
TSAURL, signatureLength, SizeIsPercent, _
ForceSettingsGUI, StopIfCertNotFound, Sign_x509, _
LastSignError, DoCAdES, IncludeCRL, PIN, Usedx509)
Once you filled the fields and signed the PDF it will look like this: muster10a_filled.pdf muster10_signed.pdf muster10_filled.pdf
More detailed in the technical howto: KBV_ITA_VGEX_Technisches_Handbuch_DiMus