Unable to iterate through a list -pyPDF2

Clash Royale CLAN TAG#URR8PPP
Unable to iterate through a list -pyPDF2
Running below code is throwing error at line pdfReader
pdfReader
pdf=['/somepath/a.pdf','/somepath/b.pdf']
for count in range(len(pdf)):
name=pdf[count]
pdfFileObj = open(name, 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj) #Error at this line
pages=pdfReader.numPages
Error- PdfReadWarning: Xref table not zero-indexed. ID numbers for objects will be corrected. [pdf.py:1736]
However when I am just passing pdf location below like this its working , but I need a loop so that every pdf can be used..
pdfFileObj = open(pdf[0], 'rb')
Even I tried look like , but it again failing at PdfReader
PdfReader
for p in pdf:
pdfFileObj = open(p, 'rb')
The fact that index zero works just means that it fails on the second file
– Mad Physicist
Aug 10 at 4:20
Thanks@MadPhysicist .So, if strict=False will be passed it will be Fixed , correct ,
– RonyA
Aug 10 at 4:57
1 Answer
1
According to this site, this error means that the first section of the xref table does not begin with object zero. You can overcome this by passing the option strict = false and PyPDF2 will automatically correct the object ID numbers. Usually this is not a big problem and Adobe will still read your PDF's. Cheers.
strict = false
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
The second form of your loop is much more pythonic
– Mad Physicist
Aug 10 at 4:20