File IO errors with PyPDF

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Henry

    #1

    File IO errors with PyPDF

    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_fi le, "rb")
    PdfOutput.addPa ge(PdfFileReade r(inp).getPage( 0))
    inp.close()

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

    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,

Working...