As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago .Are there PHP libraries which can be used to fill PDF forms and then save (flatten) them to PDF files?
2,121 1 1 gold badge 18 18 silver badges 35 35 bronze badges asked Sep 16, 2008 at 22:19 473 1 1 gold badge 5 5 silver badges 4 4 bronze badgesThis edited version of the question is hopefully a good candidte for reopen. It's been viewed >36K times and has interesting answers.
Commented Jun 14, 2015 at 9:59@jah: It's a library recommendation question, which by its very nature is off-topic. Even if it were to be reopened it'd simply be closed again with a more precise reason.
Commented Jun 16, 2015 at 6:09@jah: Perhaps if you rephrase the question "In PHP, how can I fill PDF forms and then save (flatten) them to PDF files." Seems some people can't get past the word "library".
Commented Mar 3, 2016 at 22:46The libraries and frameworks mentioned here are good, but if all you want to do is fill in a form and flatten it, I recommend the command line tool called pdftk (PDF Toolkit).
You can call the command line from php, and the command is
pdftk formfile.pdf fill_form fieldinfo.fdf output outputfile.pdf flatten
You will need to find the format of an FDF file in order to generate the info to fill in the fields. Here's a good link for that:
[Edit: The above link seems to be out of commission. Here is some more info. ]
The pdftk command can generate an FDF file from a PDF form file. You can then use the generated FDF file as a sample. The form fields are the portion of the FDF file that looks like
You might also check out php-pdftk, which is a library specific to PHP. I have not used it, but commenter Álvaro (below) recommends it.