Form Filling
Fill the fields of a PDF form with your values and download the filled PDF.
A Form Filling writes your values into the Form Fields of a PDF: the interactive fields a person would type into, tick or pick from. Its Output is the filled PDF, downloaded from the Form Filling; the Document itself never changes.
- Your values: you say what goes into each Form Field, by its name. No language model reads or fills the Document.
- Every field type: text fields, checkboxes, radio groups, combo boxes and lists, single or multiple choice.
- Fillable or flat: the filled PDF keeps its form, or with
flattenthe values become part of the pages.
🏗️ Configuration
A Form Filling is a File Operation (see Jobs): it fills the original file and never parses it.
| Parameter | Type | Default | Description |
|---|---|---|---|
values | object | required | The value of each Form Field to fill, by its full name, e.g. applicant.address.zip. At least one. |
flatten | boolean | false | Draw the Form Fields into the pages: the filled PDF can no longer be filled or edited. |
A Form Filling takes no perimeter: it always runs inside Axelered's infrastructure, so the Compliance Guard never refuses it. It costs one Credit when done.
✍️ Values
A Form Field is named by its full name: the names of its parents and its own, joined by dots. Form Fields that share a name share one value, so filling the name fills every place it appears on the pages. The Form Fields you leave out keep the value they have in the Document: fill a form in several passes, or only the fields you know.
Each type of Form Field takes one type of value:
| Form Field | Value | Example |
|---|---|---|
| Text field | A string | "Ada Lovelace" |
| Checkbox | true to tick it, false to clear it | true |
| Radio group | The name of one of its buttons | "large" |
| Combo box or list | One of its exported values | "IT" |
| Editable combo box | Any string, one of its values or not | "Lyon" |
| Multiple-choice list | An array of its exported values | ["red", "blue"] |
| Push button or signature field | None: they cannot be filled |
Values are never converted: 1 is not true, and 20121 is not "20121". A number, null or an object is no value of any Form Field, and is refused as an invalid request, 422 H_422. A choice is picked by its exported value, which can differ from the text it displays: a country list may display Italy and export IT.
Every value is checked at submit, before anything is uploaded or created. A name no Form Field has, or a value of the right type that its Form Field does not take, such as a choice it does not offer, is refused with 422 invalid_form_values, whose detail names every one of them.
Knowing the Form Fields
To learn what a form takes, read the Form Fields of its Document. They come in the order of the form, each with the value it holds in the PDF and what it takes:
curl "https://idp.axelered.com/documents/{document_id}/form-fields" \
-H "Authorization: Bearer YOUR_API_KEY"[
{
"name": "country",
"kind": "choice",
"value": "IT",
"options": [
{ "value": "IT", "label": "Italy" },
{ "value": "FR", "label": "France" }
],
"boxes": [{ "pageIndex": 0, "bbox": [0.1176, 0.2551, 0.4902, 0.2803] }]
}
]| Field | Description |
|---|---|
name | The full name: the key of its value in values. |
kind | text, checkbox, radio, choice, editable_choice, multi_choice or signature, as in the table above. A signature is listed, never filled. |
value | The value in the PDF, as a Form Filling writes it. When it holds none: false for a checkbox, [] for a multiple-choice list, null for the others. |
options | The buttons of a radio group, or the options of a choice: the exported value to fill and the label the form displays. |
boxes | Where it appears: the index of its Page and its box as fractions of the Page as shown, from its top left corner, one for each place or button. |
Reading is free and refuses what the Form Filling refuses, with the same errors (see Supported Forms). What it lists is what the Form Filling takes: fill the names it returns with values of their kind.
📄 Supported Forms
Form Filling fills interactive PDF forms (AcroForm). Any other file type is refused at submit with 400 unsupported_format, a corrupt PDF with 400 unreadable_file, and these PDFs with 422 unsupported_form, whose detail says which case it is:
| Why | |
|---|---|
| No Form Fields | A flat or scanned form has nothing to fill: its blanks are only drawn on the page. |
| XFA form | An XML form that only some viewers show; only AcroForm forms are filled. |
| Signed | Filling it would invalidate its signatures. An empty signature field is fine. |
| Encrypted | Protected by a password, even only to restrict editing: remove the protection first. |
Fonts
Each Form Field is drawn with its own font, the one set by the author of the form. A character missing from that font, such as a letter of another alphabet in a form made for Latin text, may show empty or broken. The filled PDF asks viewers to redraw its Form Fields, and most do with a font that has the character. A flattened PDF cannot be redrawn, and its choices are drawn in Helvetica: flatten only values the fonts of the form can show.
Flatten
With flatten, the Form Fields become part of the pages: the filled PDF looks nearly the same, but has no form left, so no one can change its values. A page cannot scroll, so a combo box or a list is drawn as the displayed text of what it holds, Italy and not IT: a multiple-choice list shows its picked values, separated by commas.
🛠️ Fill a Form
For every field and parameter, see the Form Fillings reference.
Submit a Form Filling
curl -X POST "https://idp.axelered.com/form-fillings?wait=30" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/application.pdf" \
-F 'config={ "values": { "name": "Ada Lovelace", "privacy": true, "size": "large", "colors": ["red", "blue"] } }'{
"status": "done",
"config": {
"values": {
"name": "Ada Lovelace",
"privacy": true,
"size": "large",
"colors": ["red", "blue"]
},
"flatten": false
},
"credits": 1
}Download the filled PDF
curl -OJ "https://idp.axelered.com/form-fillings/{form_filling_id}/output" \
-H "Authorization: Bearer YOUR_API_KEY"The file is named like the Document. The download answers 425 output_not_ready while the Form Filling runs, and 404 when it failed.
The filled PDF is not a Document: to parse it or run an Operation on it, upload it as a new Document.
Fill from another Document
To fill a form with the data of another Document, such as an application from an ID card, compose an Extraction with a Form Filling. Give the Extraction an outputSchema whose properties are the names of the Form Fields, with the types of their values, then submit its output.value as the values of the Form Filling:
{
"type": "object",
"properties": {
"name": { "type": "string" },
"privacy": { "type": "boolean" },
"size": { "type": "string", "enum": ["small", "large"] }
}
}An enum of the exported values keeps the model to the choices the form takes. Leave out of values what the Extraction returned as null: no Form Field takes it. Each Job runs and is billed on its own.
List, Read & Delete
- List Form Fillings: newest first, optionally for one Document with
?documentId=. - Read Form Filling: status, credits and configuration, with optional
wait. - Delete Form Filling: hide a Form Filling. Its Document is kept.