pdfcpu

Logo

A PDF processor written in Go.

View the Project on GitHub pdfcpu/pdfcpu


Changelog

Multifill form via JSON or CSV

This command fills form fields with data via JSON or CSV.

The workflow is similar to simple form filling except here we import a collection of form instances and generate one PDF for each.

Optionally this command can merge the output PDFs together.

Have a look at some examples.

Usage

pdfcpu form multifill inFile inFileData outDir [ outFile ] [flags]

Flags

namedescriptionrequiredvalues
m(ode)output mode (defaults to single)nosingle, merge

Common Flags


Arguments

namedescriptionrequired
inFilePDF input file containing formyes
inFileDataJSON/CSV input file with form datayes
outDiroutput directoryyes
outNameoutput file nameno

Examples

Multifill via JSON

You can generate your JSON for bulk form fills in different ways. The workflow steps are:

  1. Export your form into JSON:
$ pdfcpu form export
  1. Remove all fields which shall remain untouched.

  2. Copy & paste the form element within the forms array.

  3. Edit value (or values where appropriate) for all fields in all form instances.

  4. In addition to modifying value(s) you may change the locked status for fields.

  5. To trigger form filling run:

$ pdfcpu form multifill in.pdf in.json outDir
  1. If you are only interested in a single output file run:
$ pdfcpu form multifill in.pdf in.json outDir --mode merge

Multifill via CSV

Here the basic idea is to represent a form instance with a single CSV line in your input data file. Compared to the JSON way this will reduce the input file size dramatically but it has its limitations when it comes to expressiveness.

firstNamelastNamedobgendercitycountry
JaneDoe06.01.2000*femaleSan FranciscoUSA
JoeMiller30.07.2001*maleSão PauloBrazil
JackieCarson29.11.1965*non-binaryViennaAustria

The workflow steps are:

  1. Export your form into JSON:
$ pdfcpu form export
  1. Generate a CSV file based on the JSON file you just created and individual form data. Values prefixed with * will be locked. Each column represents a form field identified in the header line by field id:

  2. To trigger form filling run:

$ pdfcpu form multifill in.pdf in.csv outDir
  1. If you are only interested in a single output file run:
$ pdfcpu form multifill in.pdf in.csv outDir --mode merge