A one-line PDF merge command

Sep 03, '03 10:04:00AM

Contributed by: ces3001

The need arose today to merge several PDF files into one long PDF file. I looked at previous hints (1, 2), but they did not satisfy me as they forced me to enter the world of Tex.

Here is the simplest solution I came up with. As far as I know, GhostScript (gs) is included in OS X by default. In the Terminal, type:


gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf \
source1.pdf source2.pdf source3.pdf etc.pdf
All of that is one long line; it's been broken here with the backslash, so it should just copy and paste into the Terminal. It seems easy enough to wrap an AppleScript around this, as well. The -q (quiet) parameter can be omitted if you wish to see gs tell you what it's doing.

[robg adds: My PowerBook G4 has been very recently restored to a default 10.2.6 install, and GhostScript is not present, so I don't think it's included -- there's a previous hint that explains how to install it.]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2003083122212228