A PDF processor written in Go.
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 [-m(ode) single|merge] inFile inFileData outDir [outName]
name | description | required | values |
---|---|---|---|
m(ode) | output mode (defaults to single) | no | single, merge |
name | description | values |
---|---|---|
v(erbose) | turn on logging | |
vv | verbose logging | |
q(uiet) | quiet mode | |
-o(ffline) | disable http traffic | |
c(onf) | config dir | $path, disable |
opw | owner password | |
upw | user password | |
u(nit) | display unit | po(ints),in(ches),cm,mm |
name | description | required |
---|---|---|
inFile | PDF input file containing form | 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.
$ pdfcpu form multifill in.pdf in.json outDir
$ pdfcpu form multifill -m merge in.pdf in.json outDir
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:
$ pdfcpu form multifill in.pdf in.csv outDir
$ pdfcpu form multifill -m merge in.pdf in.csv outDir