Test cases / pdf

deft pdf fill

Fill a form from JSON: --data values.json

2 runs on real files, 3 tests on generated files, not shown. 0 failed.

Fixed cases

Generated files, compared with ground truth by tools other than deft.

a real tax formPassed

deft pdf fill fw9.pdf --data w9-values.json -o out.pdf

Input

fw9.pdf 137.5 KB · 6 pages
Page 1Page 2Page 3
{"topmostSubform[0].Page1[0].f1_01[0]": "Ada Lovelace"}

Output

out.pdf 135.2 KB · 6 pages
Page 1Page 2Page 3
What it printed
ok pdf.fill fw9.pdf -> out.pdf  1 fields  0.01s
Automatic checks (1)
  • pdf_text: contains = ["Ada Lovelace"], file = "out.pdf"

a ticked box without a drawing of its own gets a tickPassed

deft pdf fill latex-form.pdf --data check-values.json -o out.pdf

Input

{"Name": "Ada Lovelace", "Check": true}
latex-form.pdf 27.1 KB · 1 page
Page 1

Output

out.pdf 27.6 KB · 1 page
Page 1
What it printed
ok pdf.fill latex-form.pdf -> out.pdf  2 fields  0.00s
Automatic checks (1)
  • python: code = "import re, zlib; raw = open('out.pdf', 'rb').read(); parts = [m.group(1) for m in re.finditer(rb'stream\\r?\\n(.*?)endstream', raw, re.S)]; out = [];\nfor p in parts:\n try: out.append(zlib.decompress(p))\n except Exception: out.append(p)\nassert any(b' l S Q' in o for o in out)"