[NBLUG/talk] Concatenating pdf files

Eric Eisenhart eric at nblug.org
Fri Apr 11 11:54:00 PDT 2003


On Fri, Apr 11, 2003 at 11:00:34AM -0700, Robert Hayes wrote:
> Does anyone know of an efficient way (I'm thinking command line) to 
> concatenate several hundred pdf files?

for i in *.pdf ; do pdftops -level3 *.pdf - >> output.ps ; done ; ps2pdf14 output.ps

Caveat: this will probably lose "special" information, such as links,
bookmarks, etc.

If "ps2pdf14" isn't available, then "ps2pdf13" is a good choice.  If you
need support for old PDF versions, then "ps2pdf12" might be needed.

You may get better quality output by using "acroread -toPostScript *.pdf"
instead, such as "acroread -toPostScript *.pdf cat *.ps > output.ps ; ps2pdf
output.ps final.pdf"

For all cases of "*", you may want a specific list of files in the proper
order.

This trickery is possible because PostScript doesn't actually have a way to
say "end of file", only "end of page".  (the %%EOF is a comment; merely a
suggestion) PDF, OTOH, does know about end of file and that's messing you
up.  PDF is designed for files (and not designed for concatenation),
PostScript is designed for streams (and therefore concatenates readily)
-- 
Eric Eisenhart
NBLUG Co-Founder & Vice-President Pro Tempore
The North Bay Linux Users Group
http://nblug.org/
eric at nblug.org, IRC: Freiheit at freenode, AIM: falschfreiheit, ICQ: 48217244



More information about the talk mailing list