Yes, pdftk has this option. From man pdftk
fill_form <FDF data filename | XFDF data filename | - | PROMPT>
Fills the single input PDF's form fields with the data from an FDF file, XFDF file or stdin. Enter the data filename af‐ ter fill_form, or use - to pass the data via stdin, like so:
pdftk form.pdf fill_form data.fdf output form.filled.pdf
How to do?
1. Extract field names
pdftk forms.pdf dump_data_fields
will drop a list with e.g. entries like:
--- FieldType: Text FieldName: Name_Last FieldNameAlt: LAST FieldFlags: 0 FieldJustification: Left ---
2. Create fdf-file
fdf-files are form-fillers. We use the general notation as
<< /T(FIELD_NAME)/V(FIELD_VALUE) >>
And need to add a header and footer. Source
%FDF-1.2 1 0 obj<</FDF<< /Fields[ << /T (Name_Last) /V (Smith) >> << /T (Name_First) /V (John) >> ] >> >> endobj trailer <</Root 1 0 R>> %%EOF
To be saved as input.fdf
3. Create the document
pdftk forms.pdf fill_form input.fdf output filled.pdf
4. Maybe you want to check again?
pdftk filled.pdf dump_data_fields --- FieldType: Text FieldName: Name_Last FieldNameAlt: LAST FieldFlags: 0 FieldValue: Smith FieldJustification: Left ---
So the last name has made it into the document.
5. Additional handling
For radio buttons, the value is one of the FieldStateOption-entries, for checkboxes use V(Yes) and /V(Off).
If you want to make it more of a line-by-line query type of thing, you might want to wrap a script around it that reads the field types and names and prompts for input, then automatically creates the fdf-file. But that is a small project of its own.
Alternatively, you might like the xfdf-format (which see) better. It is based on xml-style entries.