Skip to content

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

@neofyte

Description

@neofyte

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions