Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imagemagick combine 2 generated PDFs into 1 multi-page file

I'm not finding in the documentation where to take 2 PDFs and combine them into 1 file where image1.pdf will be page 1 and image2.pdf will be page2.

Is this even possible?

I see documentation where you can pull images and do a lot of processing FROM a multi-page PDF but not on how to combine them.

**This seems to have worked but with major loss of quality. I'm sure there is a way to combine without touching PDF quality, density, degradation, etc.

exec("convert image1.pdf image2.pdf combined.pdf");

like image 458
LITguy Avatar asked Feb 06 '13 21:02

LITguy


2 Answers

Try:

convert page1 page2 output.pdf

You posted just before me :(

I think you will have to add a density.

like image 130
Bonzo Avatar answered Nov 01 '22 08:11

Bonzo


If the imagemagick on your server is able to manipulate the pdfs at all it must be using the ghostscript delegate under the hood. Try the answer used here first using ghostscript directly for best results.

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=temp.pdf pdf1.pdf pdf2.pdf
like image 19
PinnyM Avatar answered Nov 01 '22 10:11

PinnyM