Add Submit Button to PDF Document
The free Adobe Reader can be used to "export" Form Data as XML.
To use the Adobe Reader a form with a POST XML Submit Button and a server side http script (for example ASP) is required.
Please find below some functions to render fully automatic such a button to an existing PDF Document.
Sample PDF add Button VBS Script
Dim PDF
dim buttonID
set PDF = createobject("aloahapdf.edit")
If PDF.load_pdf_to_mem(cstr("c:\form.pdf"))=true then
buttonID=0
buttonID=pdf.Submit_Button_Create(cstr("Submit"),cstr("SubmitButton"), cstr("http://pki.aloaha.com/pdf/submit.asp"), cstr(""), false, clng(1), cdbl(0))
if buttonID<>0 then
if pdf.set_formfield_position(clng(buttonID), cdbl(0),cdbl(100), cdbl(700),cdbl(40)) =true then
if PDF.save_pdf_to_file(cstr("c:\targetpdf.pdf"))=true then
end if
end if
end if
end if
set PDF = nothing
Required APIs
The APIs
load_pdf_to_mem and
save_pdf_to_file are required to load first the PDF from disk to memory and write later the modified back to disk.
Submit_Button_Create
This function is required to generate the POST Button itself. The returnvalue is of type long and represents the FormFieldID of the button. A returnvalue 0 represents an error.
Submit_Button_Create(caption As String, ButtonName As String, POSTURL As String, SubmitType As String, IgnoreAnswer As Boolean, PDFPageNo As Long, fontsize As Double) As Long
-
Caption is the visible caption of the button
-
ButtonName is the internal FormFieldName
-
POSTURL is the URL the data should be posted to
-
SubmitType is reserved for future used and should be an empty string
-
IgnoreAnswer instructs the reader not to wait for an answer of the webserver
-
PDFPageNo defines the Page on which the button should be rendered
-
fontsize is the fontsize in pixel to be used. 0 is AutoSize.
set_formfield_position
This function is required to position the button on the page. values are in pixel. 0,0 is the lower, left corner of the document.
set_formfield_position(FormFieldID As Long, FFleft As Double, FFwidth As Double, FFtop As Double, FFheight As Double) As Boolean
In
FormFieldID the ID returned by create button has to be used.
Submit_Button_set_URL
This function can be used to change the URL of an existing button.
Submit_Button_set_URL(B_ID As Long, POSTURL As String, SubmitType As String, IgnoreAnswer As Boolean) As Boolean
set_formfield_color
Here you can re-define the text-, background- or bordercolour of your button.
set_formfield_color(FormFieldID As Long, Area As Long, red As Double, green As Double, blue As Double) As Boolean
-
FormFieldID is the ID of the Button
-
Area defines which object of the button has to be used.
1 -> Background Color
2 -> Border Color
3 -> Text Color
-
red/green/blue have to be values from 0 .. 1
The Borderstyle itself could be set with set_formfield_bordertype
set_formfield_bordertype
This function is to be used to define the borderstyle of a formfield or button.
set_formfield_bordertype(FormFieldID As Long, BType As Long, width As Double, dashlen As Double, spacelen As Double) As Boolean
-
FormFieldID is the ID of the Field or Button
-
BType is the Style to be used and can be any value from 0..4. Higher Numbers will define the border as solid.
-
dashlen/spacelen define the dashes when stype dashed (1) is used
Other Functions
There are lots of other functions available in Aloaha. Please contact us if you require them documented here on aloaha.com.
Interesting functions are as well:
set_FormFieldVisible(FormFieldID As Long, visible As Long) As Boolean
delete_formfield(FormFieldID As Long) As Boolean
is_button(FormFieldID As Long) as Boolean
change_FieldCaption(FormFieldID As Long, Caption as string) as Boolean
Aloaha Software / Knowledge Base / PDF Form Saver SDK / Add Submit Button