Merging pdf documents with Python

Brian briangue at
Fri Aug 20 01:05:29 CEST 2004

Assuming you've got ghostscript installed on Unix or Windows:

import os, sys

for in_file in sys.argv[1:]:
    os.system("pdf2ps %s" % in_file)

cat_cmd = 'cat '
for in_file in sys.argv[1:]:
    cat_cmd  += in_file + ".ps "
cat_cmd += ">"

os.system("ps2pdf all.pdf")
os.system("rm -f")

for in_file in sys.argv[:1]:
    os.system("rm -f" % in_file)

"Daryl Middleton" <dmidd at> wrote in message news:<mailman.1965.1092927979.5135.python-list at>...
> Can python be used to merge pdf documents into a single pdf file so that I
> do not have to manually insert each one. Thanks

More information about the Python-list mailing list