When I try to merge two .pdf files using Imagemagick

convert pdf1.pdf pdf2.pdf temp.pdf

the resulting temp.pdf file seems to have very low resolution. How can I keep the resolution same as in the source files?

link|improve this question
feedback

migrated from stackoverflow.com Oct 11 '09 at 20:50

This question came from our site for professional and enthusiast programmers.

5 Answers

Barns's right, but if pdftk didn't work try ghostscript.

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=temp.pdf pdf1.pdf pdf2.pdf
link|improve this answer
Yes. This is perfect for merging pdfs. Just download and install converter.exe from cutepdf.com/products/cutepdf/writer.asp and use your command. Except, for win32, it's gswin32c, if the GPLGS directory in the program files folder is in the path. – Shadow2531 Feb 8 '10 at 11:38
feedback

Imagemagick's convert command is normally used for converting image files from one format to another, and in this case, it is possible that it is actually performing an internal conversion of sorts before outputting the two "images" (PDFs) into a single file.

I would suggest you consider using the PDF Toolkit (pdftk) instead http://www.accesspdf.com/pdftk/

From the examples on the website, this should be as simple as:

pdftk pdf1.pdf pdf2.pdf cat output temp.pdf
link|improve this answer
I'm running on OS X 10.6.1 and I tried to install pdftk via Macports. It seems that pdftk is deprecated on Mac, the installation would not finish. So, I tried to do this using Imagemagick. – jraja Sep 27 '09 at 13:41
feedback

I'm not sure how you can keep the exact same resolution -- if that is possible with PDF at all...
But using the -density option might help. I just used this to convert some PDFs into PNGs:

convert -density 200x200 in.pdf out.png
link|improve this answer
Of course it's possible, but not like you suggest. How? See Barns or Sebastians answer. – Marco May 10 at 12:02
feedback

I couldn't find any way of joining two pdf files together while keeping the resolution good and the text intact, but I figured out a way to convert it into a high resolution png file.

pdftoppm -f 1 -l 1 -aa yes -aaVector yes -png -r 300 page.pdf > tmp1.png
pdftoppm -f 2 -l 2 -aa yes -aaVector yes -png -r 300 page.pdf > tmp2.png
convert tmp1.png tmp2.png +append -quality 100 page.png

This takes to first two pages of page.pdf and joins them into a side by side high resolution png file.

Changing the last line to

convert tmp1.png tmp2.png +append -quality 100 page.pdf

will result in a pdf document output as I later figured out after messing around with pngtopnm, pnmtops, ps2pdf.

link|improve this answer
-1 for suggesting to rasterize a (possible) vector image. That's not the way to go. – Marco May 10 at 11:59
feedback

If running linux you can also try poppler which provides pdfunite which concatenates without manipulating the resolution.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown