|Peter J. Jones f3015bf492 Add README and gemspec||7 lat temu|
|bin||7 lat temu|
|lib/pdf||7 lat temu|
|LICENSE.md||7 lat temu|
|README.md||7 lat temu|
|Rakefile||7 lat temu|
|pdf-fdf.gemspec||7 lat temu|
PDF-FDF is a Ruby library and command line tool (
pdffdf) to help
generate the FDF files necessary to fill out forms present in PDFs.
It’s especially useful in conjunction with the pdftk tool.
In the following examples the file
input.pdf is the original PDF
with form fields,
output.pdf will be the generated PDF with form
fields filled out.
Create a YAML file that contains all the form fields:
pdftk input.pdf dump_data_fields | pdffdf -ln > fields.yml
This will generate a YAML file that contains all the form fields. Additionally each field will be given a unique value starting with 0 so that you can visually identify the form fields in a test PDF.
Generate a test PDF so you can figure out which form fields have which names:
pdffdf -g fields.yml > test.fdf pdftk input.pdf fill_form test.fdf output output.pdf flatten
test.pdf file and the
fields.yml file. Using the
test.pdf file as a guide give a meaningful name in the
field for each of the form fields you care about.
Remove the generated form field values:
grep -v ' value:' fields.yml > master.yml
Fill out values for the form fields. You can set the values
directly in the
master.yml file however I recommend that you
create a new YAML file that only contains the fields you are
interested in filling out. PDF-FDF can merge an unlimited number
of YAML files into a single form field set. For this example
we’ll say that you created a new file called
is based on the
master.yml file. Also note that in your
myfields.yml file you only need to specify two keys for each
value. The other values will be found
while merging with
Create your filled out PDF:
pdffdf -g master.yml myfields.yml > form.fdf pdftk input.pdf fill_form form.fdf output output.pdf flatten