This is a somewhat weird way of doing things, since PDF files are not meant to be modified. Depending on how these PDF files were created, it can be very difficult to perform any replacement. You cannot easily change any formatting, including line breaks, so the only case that is really useful is if you have some form so that you know that the fields will match.
pyPdf may allow you to extract text, but I don’t see a function to change it while writing a second PDF. PDFedit will certainly allow you to make changes and be scriptable , but I don’t know how to connect it to Python. ReportLab only reads PDF files in the plus version if I read the page Joe Kington is right on.
I would advise you to consider why you have PDF templates, and if you really need to make changes to them, look with PDFedit - there is no description from this description, what is the structure of your documents, and it can be very difficult to find keywords.
Yann vernier
source share