How to submit your form in FormVu?
FormVu provides the FormVuAPI JavaScript API to assist with submitting your filled PDF form data. At present, this works in AcroForm files and there are four outputs supported:
How to access the FormVuAPI JavaScript API
See our related FAQ on how to access the FormVuAPI
Submit as Form Data:
To output the form data in the same format as an HTML Form, you can use the following JavaScript:
FormVuAPI.submitFormAsFormData('INSERT-URL-HERE');
This submission uses a POST request containing all form fields of the converted document. This includes the field names and their values.
It uses the same format an HTML form would use if the encoding type were set to multipart/form-data
, as such many programming languages are capable of accessing this data (e.g. via the Request.ParseMultipartData method in Go).
Example raw output:
------ExampleFormBoundaryGeneratedByTheBrowser
Content-Disposition: form-data; name="Field1"
Example Value
------ExampleFormBoundaryGeneratedByTheBrowser
Content-Disposition: form-data; name="Field2"
No
------ExampleFormBoundaryGeneratedByTheBrowser
Content-Disposition: form-data; name="Field3"
2
------ExampleFormBoundaryGeneratedByTheBrowser--
Submit as JSON:
To output the form data as JSON, you can use the following JavaScript:
FormVuAPI.submitFormAsJSON('INSERT-URL-HERE');
This will send the form data to the URL specified as a POST request.
The output JSON that is sent across is available in the following format:
{
data: {
"form-key-a": "form-value-a",
"form-key-b": "form-value-b"
}
}
Submit as XML:
To output the form data as XML, you can use the following JavaScript:
FormVuAPI.submitFormAsXML('INSERT-URL-HERE');
This will send the form data to the URL specified via a POST request.
The output XML that is sent across is available in the following format:
<?xml version='1.0' encoding='UTF-8'?>
<fields xmlns:xfdf="http://ns.adobe.com/xfdf-transition/">
<fieldName>value</fieldName>
<sanitised-field-name xfdf:original="sanitised field name">value</sanitised-field-name>
<field xfdf:original="very >bad< variable name">value</field>
<listBoxVariable>
<value>value1</value>
<value>value2</value>
</listBox>
<group xfdf:original="very >bad< listbox name">
<value>value1</value>
<value>value2</value>
</group>
</fields>
The fields are wrapped in a fields
element.
Each element within the fields
element represents a field, where the element’s name is either:
- The field name.
- The sanitised field name (when the field name contains some special characters).
- Exactly
group
if a multi list box, orfield
in all other cases.
The sanitised field name has some special characters removed, as well as spaces replaced with dashes.
When the field name has been sanitised or replaced with group
/field
, there will be an attribute called: xfdf:original
which contains the original field name, with special symbols encoded as HTML character entries.
The value of the field is usually contained within the element as text, except for multi-list boxes, where the values are contained within value
elements.
Submit as PDF:
To output the form data as PDF, you can use the following JavaScript:
FormVuAPI.submitFormAsPDF('INSERT-URL-HERE');
This will send the filled PDF to the URL specified via a POST request. By default it utilizes the same approach as a multipart/form-data
HTML form submission, with only the file
key set, containing the filled PDF file. Many programming languages provide supported ways to access this data (e.g. the $_FILES superglobal in PHP), making it easier for the endpoint to receive this data.
------ExampleFormBoundaryGeneratedByTheBrowser
Content-Disposition: form-data; name="file"; filename="DentalData.pdf"
Content-Type: application/pdf
%PDF-1.7
% ... Entire PDF file here ... %
------ExampleFormBoundaryGeneratedByTheBrowser--
Alternatively, if it is preferred that the PDF is sent directly as raw data, you can use an object as the parameter and include the submitType
attribute. The raw output PDF that is then sent to the desired endpoint:
FormVuAPI.submitFormAsFormData({url: 'INSERT-URL-HERE', submitType: 'raw'});
Note that the filename will be provided in the HTTP content-disposition
header, and that the file is sent with a content-type of application/pdf
.