I have a task where I need to fill in PDF Forms. I think they are called Acroforms but I am not sure. It is opposit to XFA Forms (embedded in PDFs), Acroforms are less dynamic, they don't have many features compared to XFA.
I am coding for NodeJS, so I tried its module pdffiller
. This library is only a wrapper for so-called pdftk
or PDF Toolkit
.
It took me almost one day to figure out how to use it on my Ubuntu 18.04 development laptop. I couldn't install it or compile, so I had to download docker image, unpack it and place compiled pdftk
in specific system folders to allow pdffiller
to work (lib goes here /usr/lib/x86_64-Linux-gnu/libgcj.so.16.0.0
, binary goes here /usr/local/bin/pdftk
).
Then there go the forms. Those downloaded from official government webpage (these are tax return forms) are XFA forms, these do not work with pdftk
- all I get is a request for password which I don't have.
Error: Failed to open PDF file:
tax-return-form.pdf
OWNER PASSWORD REQUIRED, but not given (or incorrect)
Done. Input errors, so no output created.
We took the other approach, we bought Adobe Acrobat DC to convert flat PDFs to simple Acroforms. Then we tested again what PDF Toolkit
can do. Two problems are blockers, and dim pdftk
unusable for us:
And the tax form has plenty of those checkboxes!
I would like to as what tool should we use? Is there any opensource or free for commercial use that will fill PDF Forms properly?
Edit:
I found the way to select checkboxes. After using pdftk dump_data_fields_utf8
method I got a file with a lot of information about fields:
---
FieldType: Button
FieldName: checkbox3
FieldFlags: 0
FieldJustification: Left
FieldStateOption: Off
FieldStateOption: Yes
---
The checkbox above has FieldStateOption: Off or Yes. Just putting Yes
in JSON field-value map mad checkboxes selected.
It is doable, but: