File IO errors with PyPDF

John Henry john106henry at hotmail.com
Fri Mar 9 18:59:13 EST 2007


Hi list,

I am having trouble with PyPDF (tried earlier as well as latest
version 1.9).   I am using it to combine a number of single page PDF
files into one.  It works perfectly for up to 8 files but after that,
I get a "too many files opened" message.  My code goes somewhat like:

PdfOutput = PdfFileWriter()
ofile = ...name of the combined pdf...

for doc_file in (....a bunch of single page pdf files...)
	inp=file(doc_file, "rb")
	PdfOutput.addPage(PdfFileReader(inp).getPage(0))
	inp.close()

outputStream = file(ofile, "wb")
PdfOutput.write(outputStream)
outputStream.close()

As you can see, I closed each one of the files before proceeding and
yet I get the "too many files opened" exception.

In addition, sometimes I get a "file already closed" message from
the .write function even when the number of files are small (like 5).

Anybody has any suggestions?

If not, do you have recommendations for alternative package?  My needs
are very simple - I just need to combine the single page pdfs into
one.

Regards,




More information about the Python-list mailing list