File IO errors with PyPDF

J

John Henry

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top