I have a PDF form that needs to be filled out a bunch of times (it's a timesheet to be exact). Now since I don't want to do this by hand, I was looking for a way to fill them out using a python script or tools that could be used in a bash script.
Does anyone have experience with this?
For Python you'll need the fdfgen lib and pdftk
@Hugh Bothwell's comment is 100% correct so I'll extend that answer with a working implementation.
If you're in windows you'll also need to make sure both python and pdftk are contained in the system path (unless you want to use long folder names).
Here's the code to auto-batch-fill a collection of PDF forms from a CSV data file:
Note: It shouldn't be rocket-surgery to figure out how to customize this. The initial variable declarations contain the custom configuration.
In the CSV, in the first row each column will contain the name of the corresponding field name in the PDF file. Any columns that don't have corresponding fields in the template will be ignored.
In the PDF template, just create editable fields where you want your data to fill and make sure the names match up with the CSV data.
For this specific configuration, just put this file in the same folder as your NVC.csv, NVC.pdf, and a folder named 'output'. Run it and it automagically does the rest.
Replace Original File
Much faster version, no pdftk nor fdfgen needed, pure Python 3.6+: