The Aloaha PDF Forms API can be used to access PDF Form Fields programmatically. Please find below an overview of the possible functions. Please note that the Aloaha PDF Saver Professional is required. It is not possible with the Standard Edition of the Aloaha PDF Form Saver.
To be able to access the functions please create the object.
set PDF = createobject("aloahapdf.edit")
Next you need to load the PDF Form to be edited to memory. The parameter can be a local file or a remote file hosted on a webserver. For example http://www.aloaha.com/cache/fs5.pdf
If PDF.load_pdf_to_mem(cstr(c:\form.pdf)) =true then
msgbox "Form loaded to memory"
if PDF.FormFields>0 then
msgbox "PDF is Form"
msgbox "PDF is not a Form"
msgbox "Could not load Form to memory"
To be able to set or read a Form Value you need to select the FormField.
Form Fields can be selected by ID Number or FormTitle. To select a FormField by ID Number is faster. IDs always start at 1.
if PDF.SelectFormField(clng(1))=true then
msgbox "First FormField selected"
msgbox "Could not select FormField"
In case the ID Numbers of your Form are not known its easier to select the the FormField by Title.
if FormFieldID>0 then
if PDF.SelectFormField(clng(FormFieldID))=true then
msgbox "FormField "&cstr("FirstName")&" with ID Number "&cstr(FormFieldID)&" selected"
msgbox "Could not find FormField"
else msgbox "Could not find FormField"
Sometimes FormFields can contain SubObjects. To detect such an subobject please call
If PDF.FormFieldSubs>0 then
msgbox "Form Field contains Subjobjects"
In case a FormField contains subjobjects you can call SelectFormFieldSub to select one of such objects.
if PDF.SelectFormFieldSub(2)=true then
msgbox "Subobject 2 selected"
msgbox "Could not select Subobject"
Now you can set or read the formfield value.
To Read the FormField Value call:
To set a value call the following code:
if PDF.SetFormFieldValue(cstr("This is the new value"))=true then
msgbox "Value set"
msgbox "Could not set Value" end if
After you set all required values you must save the PDF Document from Memory to Disk.
Please use the command save_pdf_to_file:
if PDF.save_pdf_to_file(cstr("c:\targetpdf.pdf"))=true then
msgbox "PDF Saved to Disk"
msgbox "Could not Save PDF to Disk"
Now remove the PDF Object from memory if you do not need it anymore.
set PDF = Nothing
Additional Form Field Functions
1. get_formfieldTitle(FieldID) returns the Form Field Title for a given FieldID.
2. get_fieldValue_byTitle(FormFieldTitle) returns the form field value for a given Field directly whithout selecting it before.
3. SetFormFieldValue_by_Name(FormFieldTitle, NewValue) sets Form Field by Title. It works directly without having to select the field before.
4. SetFormFieldValue_by_ID(FieldID, NewValue) sets Form Field by Formfield ID. It works directly without selecting the field before.
5. seal_all_fields flattens all form fields
6. sealform(FieldID) seals/flattens given Formfield
7. set_formFieldReadOnly(FieldID) sets a Formfield read only.
8. make_all_fields_readonly renders all Formfields read-only.
9. delete_formfield deletes a formfield by ID
10. set_FormFieldVisible can be used to toggle a field visible or unvisible.
11. set_formfield_color sets colors of fields
12. set_formfield_bordertype defines the bordertype of a field
13. set_formfield_position sets/moves a field to a given position.
Although we really tried hard, there are always questions left open. But perhaps somebody else had already put the same question? Please check!
When using GetFormFieldTitle(FieldID) I get an error "Object doesn't support this property or method". Why?
Please use get_formfieldTitle(clng(fieldID))
Do you have help documentation?
Please use our website as a reference. Should you have further questions please contact firstname.lastname@example.org
I'm looking to take a web form, and have a submit button essentially that then creates a pdf document using form values from the web page. Is your software capable of doing something like this.
All APIs required for such an application are included in the Aloaha Form Saver SDK. If you have further questions or need assistance while implementing please do not hesitate to contact email@example.com
If not, please do not hesitate to send us your question. We would be glad to answer it.