PdfFileReader: PdfReadError: Could not find xref table at specified location

Nitin Bhojwani picture Nitin Bhojwani · Dec 5, 2015 · Viewed 7.5k times · Source

I am trying to read Pdf file in python through:

from PyPDF2 import PdfFileReader, PdfFileWriter
test_reader = PdfFileReader(file("test.pdf", "rb"))

Above Line throws error:

PyPDF2.utils.PdfReadError: Could not find xref table at specified location

Any help will be highly appreciated

Answer

Nitin Bhojwani picture Nitin Bhojwani · Dec 6, 2015

It's fixed. Actually, there wasn't any problem. Seems, the pdf I was using to test was corrupted one (even though when I opened it, the content was there, which is why I couldn't figure out at first place)

I replaced it with another one and it worked as expected.