473,395 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Merging pdf documents with Python

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

Jul 18 '05 #1
4 2650
ReportLab has a product (not free) called PageCatcher
that provides this capability. I've used it in
several projects and it works perfectly.

HTH,
Larry Bates
Syscon, Inc.

"Daryl Middleton" <dm***@chartermi.net> wrote in message
news:ma**************************************@pyth on.org...
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

Jul 18 '05 #2
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 += "> all.ps"

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

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

"Daryl Middleton" <dm***@chartermi.net> wrote in message news:<ma**************************************@pyt hon.org>...
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

Jul 18 '05 #3
"Daryl Middleton" <dm***@chartermi.net> writes:
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


I was using a free version of PageCatcher (ReportLab) for awhile
(after using PJscript and Ghostscript). My projects manipulate
PDF submitted by hundreds of people so any incompatibility is
likely to be a problem. ReportLab couldn't handle everything we
got last year so I started searching again.

I ended up with iText.
http://itext.sourceforge.net/
It has been very solid. There was a problem once but it was
quickly fixed.
http://groups.google.com/groups?q=it...rds.org&rnum=3

I usually hate using Java but I don't mind using iText through
Jython. When I use it from Zope I use os.system like this.
command = 'java -cp /var/lib/zope/instance/default/Extensions/itext-paulo-130.jar com.lowagie.tools.concat_pdf ' + string.join(piece_names) + ' ' + result_name

I'm quite happy with iText. I like that it's Free and well-
maintained. Being usable from Jython is a real bonus.

--kyler
Jul 18 '05 #4
"Daryl Middleton" <dm***@chartermi.net> writes:
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


pdflatex with pdfpages is your friend. Of course you can make a
python script that runs it.
--
Brian (remove the sport for mail)
http://www.et.dtu.dk/staff/be
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Nash | last post by:
Hi guys I wonder if you could help. I'm trying to create a bespoke interface for mail merging from an Access database in Word. At the moment, I'm just trying it with CSV files, and it works....
1
by: Mael Guillemot | last post by:
Hi, I have one xml looking like this: ========================= <video> <shot id="1"> <timestampbegin>000030.90</timestampbegin> <feature>blabla</feature>...
3
by: William Ahern | last post by:
I'm looking for resources on splitting and merging XML trees. Specifically, on methods to pare large XML documents into smaller documents which can be merged later. Off of the top of my head, I...
1
by: Yannick Patois | last post by:
Hi, I would like to merge two XML document, or more exacly enrich a document by inheritiong from another. I read a bit about XSLT and I know a bit of python/sax/dom, and I dont know where I...
2
by: North Country Boy | last post by:
Hi I'm trying to run the mail merge operation in MS Word from within Javascript. I've already done this in VB but I'm having problems trying to do the same thing in Javascript. First I am trying...
3
by: Patrick | last post by:
I have got 2 XML documents, both of which conform to the same XSD Schema, which define possible optional elements. The 2 XML documents contain 2 disjoint set of XML elements. What is the best,...
0
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather...
2
by: Garikayi Mukombachoto | last post by:
Hi I would really appreciate any assistanance with the following situation. Lets say i have 2+ documents A,B,...n that i need to merge together, such that the resulting documents contains...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.