
PDF tooling for Go and the command line.
View the Project on GitHub pdfcpu/pdfcpu
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.
pdfcpu form multifill inFile inFileData outDir [ outFile ] [flags]
| name | description | required | values |
|---|---|---|---|
| m(ode) | output mode (defaults to single) | no | single, merge |
| name | description | required |
|---|---|---|
| inFile | PDF input file containing form, use - to read from stdin | yes |
| inFileData | JSON/CSV input file with form data | yes |
| outDir | output directory | yes |
| outName | output file name | no |
You can generate your JSON for bulk form fills in different ways. The workflow steps are:
$ pdfcpu form export
Remove all fields which shall remain untouched.
Copy & paste the form element within the forms array.
Edit value (or values where appropriate) for all fields in all form instances.
In addition to modifying value(s) you may change the locked status for fields.
To trigger form filling run:
$ pdfcpu form multifill in.pdf in.json outDir
$ pdfcpu form multifill in.pdf in.json outDir --mode merge
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.
| firstName | lastName | dob | gender | city | country |
|---|---|---|---|---|---|
| Jane | Doe | 06.01.2000 | *female | San Francisco | USA |
| Joe | Miller | 30.07.2001 | *male | São Paulo | Brazil |
| Jackie | Carson | 29.11.1965 | *non-binary | Vienna | Austria |
The workflow steps are:
$ pdfcpu form export
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:
To trigger form filling run:
$ pdfcpu form multifill in.pdf in.csv outDir
$ pdfcpu form multifill in.pdf in.csv outDir --mode merge
For multifill, outDir is still used for generated form instances even when the merged PDF is written to stdout:
$ aws s3 cp s3://acme-forms/application.pdf - \
| pdfcpu form multifill --mode merge - applications.csv /tmp/pdfcpu-forms - \
| aws s3 cp - s3://acme-forms/applications-merged.pdf