views:

195

answers:

2

Currently I am using ImageMagick to merge multiple PDFs into one in a PHP script on my Linux system. However, the resulting PDFs are of very low quality. I have stumbled across pdftk which seems to have a better quality after the merging, but I need to use ImageMagick if possible because I need to get the script to run on another server which does not have pdftk (and it would be a pain to get it on there).

How can I merge PDFs using ImageMagick and PHP with lossless quality?

+4  A: 

ImageMagick can't do lossless PDF merging. If you have a Linux server, you may try pdfconcat (which does lossless merging very quickly):

$ wget -O pdfconcat http://www.math.bme.hu/~pts/cvsget.cgi/u=bin.i386/p=/M=bin.i386/c=f1/n=/bin.i386/pdfconcat
$ chmod +x pdfconcat
$ ./pdfconcat -o output.pdf input1.pdf input2.pdf input3.pdf
pts
that's pretty cool; definitely going to be adding this to my workstation :)
warren
A: 

My CAM::PDF Perl library includes a flexible command-line tool called appendpdf.pl which can mix arbitrary pages of a PDF into another document.

Chris Dolan