Browse Source

Add README and gemspec

master
Peter J. Jones 7 years ago
parent
commit
f3015bf492
3 changed files with 86 additions and 0 deletions
  1. 53
    0
      README.md
  2. 15
    0
      Rakefile
  3. 18
    0
      pdf-fdf.gemspec

+ 53
- 0
README.md View File

@@ -0,0 +1,53 @@
# PDF-FDF

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.

[pdftk]: http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

## Typical Workflow

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.

1. 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.

2. 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

3. Open the `test.pdf` file and the `fields.yml` file. Using the
`test.pdf` file as a guide give a meaningful name in the `alias`
field for each of the form fields you care about.

4. Remove the generated form field values:

grep -v ' value:' fields.yml > master.yml

5. 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 `myfields.yml` that
is based on the `master.yml` file. Also note that in your
`myfields.yml` file you only need to specify two keys for each
form field: `alias` and `value`. The other values will be found
while merging with `master.yml`.

6. Create your filled out PDF:

pdffdf -g master.yml myfields.yml > form.fdf
pdftk input.pdf fill_form form.fdf output output.pdf flatten

+ 15
- 0
Rakefile View File

@@ -0,0 +1,15 @@
################################################################################
require('rake/testtask')

################################################################################
Rake::TestTask.new do |t|
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end

################################################################################
desc("Build a gem")
task(:gem) {system('gem', 'build', 'pdf-fdf.gemspec')}

################################################################################
task(:default => :test)

+ 18
- 0
pdf-fdf.gemspec View File

@@ -0,0 +1,18 @@
################################################################################
$:.unshift(File.expand_path('lib', File.dirname(__FILE__)))
require('pdf/fdf/version')

################################################################################
Gem::Specification.new do |gem|
gem.name = 'pdf-fdf'
gem.version = PDF::FDF::VERSION
gem.platform = Gem::Platform::RUBY
gem.authors = ['Peter Jones']
gem.email = ['pjones@pmade.com']
gem.homepage = 'http://github.com/pjones/pdf-fdf'
gem.summary = 'Library and command line tool for generating FDFs.'
gem.description = File.read('README.md')
gem.files = Dir.glob('{bin,lib}/**/*') + %w(README.md LICENSE.md)
gem.executables = ['pdffdf']
gem.require_path = 'lib'
end

Loading…
Cancel
Save