Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it a bug? #67

Closed
yiqiyu opened this issue Jun 22, 2018 · 4 comments
Closed

Is it a bug? #67

yiqiyu opened this issue Jun 22, 2018 · 4 comments

Comments

@yiqiyu
Copy link

yiqiyu commented Jun 22, 2018

I met this when trying to open a pdf:

Traceback (most recent call last):
  File "D:/P4/y/y/pledge_extraction/main.py", line 49, in read_pdf2
    with pdfplumber.open(file) as pdf:
  File "C:\Users\yyq\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfplumber\pdf.py", line 40, in open
    return cls(open(path, "rb"), **kwargs)
  File "C:\Users\yyq\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfplumber\pdf.py", line 34, in __init__
    self.metadata[k] = decode_text(v)
  File "C:\Users\yyq\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pdfplumber\utils.py", line 68, in decode_text
    ords = (ord(c) if type(c) == str else c for c in s)
TypeError: 'bool' object is not iterable

It seems that pdfplumber isn't correctly handling boolean values in documents' metadata

@jsvine
Copy link
Owner

jsvine commented Jun 25, 2018

Hi @yiqiyu, and thanks for flagging. That does look like it might be a bug. Do you have an example of a PDF that raises this error?

@yiqiyu
Copy link
Author

yiqiyu commented Jun 26, 2018

ST东电_2018年第一季度报告全文_2018-04-28_1204826502.pdf

Yes, @jsvine . Please see the attachment.

@Yevgnen
Copy link
Contributor

Yevgnen commented Jul 11, 2018

Same here.

jsvine added a commit that referenced this issue Jul 11, 2018
Thanks to @yiqiyu for the example PDF!
@jsvine
Copy link
Owner

jsvine commented Jul 11, 2018

Thanks again for flagging this and providing the example PDF. And thanks to @Yevgnen for the fix. Merged and now available in v0.5.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants