Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python PDFMiner error: "No /Root object! - Is this really a PDF?"

I am getting this error "No /Root object! - Is this really a PDF?" using my MAC computer with Python 2.7 and PDFMiner version 20110515. The pdf files are not damaged because the same program with the same files works on my PC computer! Also I have tried many pdfs and this error exists for all of them. Any ideas of what I should change in my MAC to not to get this error?

like image 344
Mahshid Zeinaly Avatar asked Jun 26 '13 22:06

Mahshid Zeinaly


1 Answers

I found the source of the problem:

I had a method to read all the files in a directory and parse them. Turns out that I had one hidden file in that directory that was not a pdf file!

Here is how I fixed the problem:

for filename in os.listdir(INPUT_DIR_NAME):
    if filename.endswith('.pdf'):
        #do stuff!
like image 108
Mahshid Zeinaly Avatar answered Oct 29 '22 16:10

Mahshid Zeinaly