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

TypeError: a bytes-like object is required, not 'str' #423

Closed
xiaocuigit opened this issue May 10, 2020 · 1 comment · Fixed by #734
Closed

TypeError: a bytes-like object is required, not 'str' #423

xiaocuigit opened this issue May 10, 2020 · 1 comment · Fixed by #734

Comments

@xiaocuigit
Copy link

xiaocuigit commented May 10, 2020

Traceback (most recent call last):
  File "/anaconda3/bin/pdf2txt.py", line 4, in <module>
    __import__('pkg_resources').run_script('pdfminer.six==20200402', 'pdf2txt.py')
  File "/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 666, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1462, in run_script
    exec(code, namespace, namespace)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/EGG-INFO/scripts/pdf2txt.py", line 192, in <module>
    sys.exit(main())
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/EGG-INFO/scripts/pdf2txt.py", line 186, in main
    outfp = extract_text(**vars(A))
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/EGG-INFO/scripts/pdf2txt.py", line 57, in extract_text
    pdfminer.high_level.extract_text_to_fp(fp, **locals())
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/high_level.py", line 86, in extract_text_to_fp
    interpreter.process_page(page)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/pdfinterp.py", line 896, in process_page
    self.device.end_page(page)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 51, in end_page
    self.receive_layout(self.cur_item)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 442, in receive_layout
    render(ltpage)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 392, in render
    render(child)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 434, in render
    render(child)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 426, in render
    render(child)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 438, in render
    item.size)
  File "/anaconda3/lib/python3.6/site-packages/pdfminer.six-20200402-py3.6.egg/pdfminer/converter.py", line 362, in put_text
    fontname_without_subset_tag = font
name.split('+')[-1]
TypeError: a bytes-like object is required, not 'str'

This is the test pdf file: dddd.pdf
I use the command: pdf2txt.py dddd.pdf -t html -o ddd.html

@pietermarsman
Copy link
Member

I can replicate this.

Only happens when -t html is used, so probably something is wrong in the HtmlConverter.

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

Successfully merging a pull request may close this issue.

2 participants