2

When I try to using pdftk my.pdf dump_data_fields >result.txt have empty data result

  • My PDF had been written using Chrome's Print to Save PDF. Looked in every way like a completed form from Adobe Acrobat but pdftk did not see fields as fields anymore. Using pdftk uncompress showed the field values were there just not any fields. Currently using pdftotext but that has it's own issues with ignoring check boxes. – rob Jun 25 '18 at 13:20

2 Answers2

1

Your file my.pdf may not be compatible with pdftk. Convert the file first using the following command:

>pdftk my.pdf output my_converted.pdf

Then try,

>pdftk my_converted.pdf dump_data_fields > result.txt

I've taken this from the following http://www.fpdf.org/en/script/script93.php where the converting process is suggested when the fields won't write to the pdf file so converting before dumping the fields may not help. If your pdf has fields you it should be fillable in your pdf viewer. If in isn't fillable then it would seem that it has no fields.

Peter Cook
  • 11
  • 3
0

This is most likely because the pdf you are using doesn't have any data fields to dump! Use a tool like Adobe Acrobat to open the pdf, go to wherever you need to to Edit Fields, and add fields anywhere you need them to show up. Make sure they are named so you can utilize them by using the attributes[] call in pdftk.

I recommend using snake case (i.e. text box named 'first_name') and then you should have access to it using attributes[:first_name] = 'your text'.

Hope this helps, let me know if you have any other questions/issues.

David Routen
  • 349
  • 4
  • 21