colemana / PyPDF2

A utility to read and write pdfs with Python. Superseded: see https://github.com/knowah/PyPDF2
Other
80 stars 19 forks source link

error: Can't convert 'bytes' object to str implicitly #5

Open neofyte opened 11 years ago

neofyte commented 11 years ago

I am porting my script from python27 to python33. When I run the code pdf = PdfFileReader(open('xxxx.pdf', 'rb')), the error message appears:

Traceback (most recent call last):
File ..., in <module>raw_content = pdf.getPage(0).extractText()
File "C:\Python33\lib\site-packages\PyPDF2\pdf.py", line 1718, in extract Textcontent = ContentStream(content, self.pdf)
File "C:\Python33\lib\site-packages\PyPDF2\pdf.py", line 1797, in __init__data += s.getObject().getData()
TypeError: Can't convert 'bytes' object to str implicitly

On the other hand, I cannot open the file with

pdf = PdfFileReader(open('xxxx.pdf', 'r'))

otherwise, it comes the following messages:

io.UnsupportedOperation: can't do nonzero end-relative seeks

What's going wrong?

juankysmith commented 10 years ago

I am having the same problem :( Have you found any solution?

jdkanani commented 10 years ago

Same problem :(

james-see commented 8 years ago

According to docs you can't seek the end of a file without the beginning for python 3.2+. I am having the same issue.

beigi commented 6 years ago

same problem