What happened? What were you trying to achieve?
I am trying to read text from a pdf file. But I am getting an error which I don't think is because of my code. The code crashes for the particular pdf mentioned below.
Environment
Which environment were you using when you encountered the problem?
$ python -m platform
Windows-10-10.0.22000-SP0
$ python -c "import PyPDF2;print(PyPDF2.__version__)"
2.10.9
Code + PDF
This is a minimal, complete example that shows the issue:
if afile.endswith(".pdf"):
pdfReader = PyPDF2.PdfFileReader(open(afile, "rb"), strict=False)
texts = pdfReader.getPage(0).extract_text() # the ERROR happens on this line !!!!!
for kw in keywords:
if kw not in texts: return False
# pbar.write(f'{kw} found')
return True
PDF file: https://d4duas3s44z1s.cloudfront.net/Dat2020Live/document/test/question/Question_Report_299.pdf
don't add them to your tests!
Traceback
This is the complete Traceback I see:
File "path\to\there\Python\Python310\lib\site-packages\PyPDF2\_cmap.py", line 291, in parse_bfrange
unhexlify(fmt % a).decode(
binascii.Error: Odd-length string
What happened? What were you trying to achieve?
I am trying to read text from a pdf file. But I am getting an error which I don't think is because of my code. The code crashes for the particular pdf mentioned below.
Environment
Which environment were you using when you encountered the problem?
$ python -m platform Windows-10-10.0.22000-SP0 $ python -c "import PyPDF2;print(PyPDF2.__version__)" 2.10.9Code + PDF
This is a minimal, complete example that shows the issue:
PDF file: https://d4duas3s44z1s.cloudfront.net/Dat2020Live/document/test/question/Question_Report_299.pdf
don't add them to your tests!
Traceback
This is the complete Traceback I see: