Digital Signature API Code sample

Please find below a code sample for the Aloaha digital signature API. A 25+ license is required to use the digital signature API. Please contact us for an evaluation key. The code sample can be downloaded here.



Simplified code can bee seen here!


'This sample script demonstrates how to sign PDF Document
'with Adobe.PPKMS signatures
'Copyright 2005 Wrocklage Intermedia GmbH
'Redistribution without permission not allowed
'Signature API only enabled with Aloaha PDF Suite Enterprise Version.


Dim pdf             'aloaha object
Dim reason      'signature reason
Dim location     'signature physical location
Dim infile           'inputpdf
Dim outfile         'outputpdf - can be the same as inputpdf
Dim image        'image to be used for signature - empty string allowed
Dim cert             'certificate to be used. Can be either UniqueContainerName or Serialnumber
Dim x1                'x start mediabox
Dim y1                'y start mediabox
Dim x2                'x end mediabox
Dim y2                'y end mediabox
Dim ph               'pageheight - 0 for auto
Dim pw               'pagewidth - 0 for auto
Dim xoff              'x-offset if page does not start at 0
Dim yoff              'y-offset if page does not start at 0
Dim mediabox  'mediabox string
Dim page           'page to be used
Dim px1              'x1 coordinate as percentage of full page (upper left)
Dim py1              'y1 coordinage as percentage of full page (upper left)
Dim px2              'x2 coordinage as percentage of full page (lower right)
Dim py2              'y2 coordinage as percentage of full page (lower right)

px1 = 84
py1 = 8

px2 = 99
py2 = 2

xoff = 0
yoff = 0

reason = "I created this document"
location = "I am in the office" 


'set unique container name of certificate. serialnumber can be also used
cert ="9e82c38e348ddcf70d58e0a21f56d6f6_dc4ff486-0fc3-4b64-b582-b94a2eba4ba5" 

'set page where signature will be shown
page = 1 

'set file names
infile = "c:\pdf\input.pdf"
outfile = "c:\pdf\output.pdf"

'create object
Set pdf = CreateObject("aloahapdf.edit")
 
         pdf.currentpage = CLng(page)
 
         'set signature imagepath. Must be a color jpg file.
         'Empty string also possible
         image = pdf.aloahapath+"jpg\george1.jpg"
 
         'mediabox etc only needed if pagesize is unknown
         'and autodetect should not be used. 
         mediabox = pdf.get_pagesize_s(CStr(infile),CLng(page))

         If mediabox<>"" Then
              x1=Trim(split(mediabox)(0))
              y1=Trim(split(mediabox)(1))
              x2=Trim(split(mediabox)(2))
              y2=Trim(split(mediabox)(3))
              ph=Abs(y2-y1)
              pw=Abs(x2-x1)
     Else
              ph=0
              pw=0
     End If
 
 'set pageheight and pagewidth to 0 for autodetect
 'ph=0
 'pw=0
 
 If ph >0 Then
      yoff = ((y1/ph)*100)\1
 Else
      yoff = 0
 End If
 If pw >0 Then
      xoff = ((x1/pw)*100)\1
 Else
      xoff = 0
 End if              


            Call pdf.sign_pdf_file(CStr(infile), CStr(outfile), CLng(pw), CLng(ph), CLng(px1+xoff), CLng(py1+yoff), CLng(px2+xoff), CLng(py2+yoff), CStr(reason), CStr(location), CStr(cert), CStr(image))
 
Set pdf = nothing  



Sample PDF Document


Aloaha Software / Products / Aloaha PDF Suite Enterprise / PDF Signature API

create PDF Software

PDF Signature API

Any questions?
Aloaha Software - Signature Code, digital, pdf, vbs, asp, code, api, sdk
ProductsKnowledge BaseShopSupportPress
Deutsche VersionEnglish version