Concatenating PDFs in PHP
I've got a grip of PDFs that I need to combine into one using PHP. Googling around gives me very little that seems like a reasonable solution. The best thing I can find is to use exec() and pdftk but that's just ugly. Does anyone know of a more elegant solution tha开发者_开发问答t doesn't involve me shelling out all the money on the planet for some non-free lib?
Would FPDF AND FPDI work?
http://www.setasign.de/products/pdf-php-solutions/fpdi/demos/concatenate-fake/
Make sure you have FPDF 1.6. This is what I tested with.
Regards.
You could utilize a PHP/Java bridge to get access to iText.
Actually, the homepage of the bridge component has an example with concatenation of PDFs.
Not sure if there is a pure PHP-based solution, because exec()
is really not that ugly as you might think. As an alternative for pdftk
you can use Ghostscript:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf header.pdf example.pdf
精彩评论