Has it ever happened to you that you fill out a PDF form and when you sended to someone else, that person has received an empty form? I will teach you one way to fix these errors by using pdftk.

pdftk is a great PDF tool (see Encrypting PDFs) and one thing it can do is extracting text from a form and re-add it as a plain text (removing the form inputs).

Script below takes two arguments: the input and output file. It will create a temporary file (inside working directory) with the form info. You can delete the file after the process if you want. After extracting the form inputs, it will fill out the PDF again but it will “flatten” it, i.e. it will convert the form inputs to plain text.

# ./flat-forms

TEMPFILE=`basename -s .pdf $INPUT`.fdf

pdftk $INPUT generate_fdf output $TEMPFILE
pdftk $INPUT fill_form $TEMPFILE output $OUTPUT flatten
./flat-forms input.pdf output.pdf