Governments and insurers still publish dynamic XFA forms, the ones that show “Please wait…” in every other viewer. xfaf reads them on a server with no Acrobat: it lists the fields, maps which field drives which, fills the form from a JSON file and writes a PDF back.
Edit the values on the left. This panel is an illustration that runs in your browser; the field names, captions and choice codes are the ones xfaf extracts from a real Canadian immigration form.
Each one reads a PDF and prints JSON or writes a file. Output below is from real runs, shortened.
Tells an XFA form from an AcroForm or a plain PDF, and counts fields and scripts before you commit to anything.
$ xfaf inspect imm5645.pdf
{
"pdf_type": "xfa_static",
"pages": 2,
"xfa": {
"fields": 151,
"scripts": {
"total": 44,
"javascript": 44,
"formcalc": 0
}
}
}
Path, type, caption, whether it is required or read-only, and the choices of each dropdown with both the label and the stored value.
$ xfaf extract imm5645.pdf -o form.json
{
"name": "ChildMStatus",
"path": "IMM_5645.page1.SectionA.Applicant.ChildMStatus",
"type": "dropdown",
"caption": "Marital status:",
"required": false,
"access": "open",
"choices": [
{"value": "1", "label": "Annulled marriage"},
{"value": "2", "label": "Common-law"},
{"value": "7", "label": "Single"}
]
}
Reads the JavaScript inside the form and reports, for each script, the fields it reads and the field it changes. Needs Node installed.
FormCalc scripts are listed as not analysed.
$ xfaf graph imm5645.pdf
{
"driver": "Language",
"driven": "FormNumber",
"access": "read",
"script": "FormNumber_ready_5",
"event": "ready"
}
--template prints a JSON file with every field path and its current value. Edit it, pass it back, get a filled PDF. Unknown keys are reported, not ignored.
$ xfaf fill --template imm5645.pdf > data.json $ xfaf fill imm5645.pdf data.json -o filled.pdf { "filled": 2, "skipped": {}, "errors": [] }
Writes one self-contained HTML file with the form's sections, captions and choices, for showing the form to people who cannot open it.
$ xfaf html imm5645.pdf -o form.html --report report.json $ ls form.html report.json
Read these before you rely on it.
Python 3.10 or later. Three dependencies: pikepdf, lxml and defusedxml. Node is needed only for graph.
# from a copy of the source
pip install -e .
xfaf inspect your-form.pdf
xfaf is not on PyPI yet and the source is not public yet.