0
votes

When running this code

import PyPDF2 as pdf

bikeins = open('pdffileproj12.pdf','rb')
read_bikeins = pdf.PdfFileReader(bikeins)

I get this error

read_bikeins = pdf.PdfFileReader(bikeins) Traceback (most recent call last):

File "", line 1, in read_bikeins = pdf.PdfFileReader(bikeins)

File "C:\Users\Naveen Raj\Anaconda3\lib\site-packages\PyPDF2\pdf.py", line 1084, in init self.read(stream)

File "C:\Users\Naveen Raj\Anaconda3\lib\site-packages\PyPDF2\pdf.py", line 1805, in read assert xrefstream["/Type"] == "/XRef"

TypeError: string indices must be integers

Find the PDF here

1
What is the value of bikeins?Reut Sharabani
can you share your pdffileproj.pdf fileBentaye
@Bentaye how to share my Pdf file here. can i send u the pdf file personallyNaveen Raj B
@NaveenRajB maybe give a dropbox or goggle drive link to the file. Not sure if it is possible to upload a file here.Bentaye

1 Answers

0
votes

Disclaimer: This is not an answer, I post it as an answer because the original poster asked for it and because it won't fit in a comment, length wise and format wise.

Here is the code I run. And I can't reproduce the error.

  • I run on MacOs
  • I am using the provided pdf file.
  • The pdf file is in the same folder as the program.
  • Tried both Python 2.7.13 and 3.6.3

The file is in the same folder at the test.py file.

import PyPDF2 as pdf

bikeins = open('pdffileproj12.pdf','rb')
read_bikeins = pdf.PdfFileReader(bikeins)

print(str(read_bikeins))

Here is the output when I run it, with Python 2.7.13

$ python --version
Python 2.7.13
$ python test.py 
<PyPDF2.pdf.PdfFileReader object at 0x101618810>

and with Python 3.6.3

$ python3 --version
Python 3.6.3
$ python3 test.py 
<PyPDF2.pdf.PdfFileReader object at 0x110588c88>

I do not get any error. Can you check your version of Python?