I am doing bulk template-based pdf generation and I quickly ran into big performance issues. My current scenario is as follows:
- Get data to fill out from db
- create fdf based on one line of data and pdf form
- write the
.fdf file to disk - merge a PDF file with fdf using pdftk (fill_form using the flatten command)
- continue iterating through the lines until all
.pdf are created - all generated files are combined together at the end and one PDF file is provided to the client
I use passthru to give raw output to the client (saves a time record file), but this is only a slight performance improvement. The total run time is about 50 seconds for 200 records, and I would like to go down to at least 10 seconds.
An ideal script will work with all these pdf files in memory and not write any of them to split the file, but then the output will be impossible, since I cannot transfer such data to an external tool like pdftk. Another idea was to generate one large .fdf file with all these lines, but it looks like it is forbidden.
Did I miss something very trivial here?
I am grateful for any advice.
PS. I know that I can use some good library, for example pdflib, but now I am considering only open licensed libraries.
EDIT:
I guess that the syntax for creating the .fdf file with multiple pages, using the same pdf file as the template, spent several hours and could not find good documentation.
Nazar Gargol
source share