Giter Club home page Giter Club logo

Comments (3)

peturjokull avatar peturjokull commented on August 11, 2024

I had the same error so I added decode to the byte part and it worked for me

page_label = label_format['P'].decode('utf-8')+page_label

from pdfquery.

gskriptor avatar gskriptor commented on August 11, 2024

@peturjokull I tried your fix, but my script is just stuck running. When I stop it with ctl C I get this error message. My script is from the pdfquery examples. Seems like there is something up with the pdf.load() funciton.

^CTraceback (most recent call last):
File "loadtest.py", line 4, in
pdf.load()
File "/usr/local/lib/python3.7/dist-packages/pdfquery/pdfquery.py", line 385, in load
self.tree = self.get_tree(*_flatten(page_numbers))
File "/usr/local/lib/python3.7/dist-packages/pdfquery/pdfquery.py", line 487, in get_tree
for n, page in pages:
File "/usr/local/lib/python3.7/dist-packages/pdfquery/pdfquery.py", line 608, in
return (self.get_layout(page) for page in self._cached_pages())
File "/usr/local/lib/python3.7/dist-packages/pdfquery/pdfquery.py", line 601, in get_layout
self.interpreter.process_page(page)
File "/usr/local/lib/python3.7/dist-packages/pdfminer/pdfinterp.py", line 842, in process_page
self.device.end_page(page)
File "/usr/local/lib/python3.7/dist-packages/pdfminer/converter.py", line 48, in end_page
self.cur_item.analyze(self.laparams)
File "/usr/local/lib/python3.7/dist-packages/pdfminer/layout.py", line 680, in analyze
self.groups = self.group_textboxes(laparams, textboxes)
File "/usr/local/lib/python3.7/dist-packages/pdfminer/layout.py", line 647, in group_textboxes
if c == 0 and isany(obj1, obj2):
File "/usr/local/lib/python3.7/dist-packages/pdfminer/layout.py", line 627, in isany
objs = set(plane.find((x0, y0, x1, y1)))
File "/usr/local/lib/python3.7/dist-packages/pdfminer/utils.py", line 322, in find
for k in self._getrange(bbox):
File "/usr/local/lib/python3.7/dist-packages/pdfminer/utils.py", line 285, in _getrange
for x in drange(x0, x1, self.gridsize):
KeyboardInterrupt

from pdfquery.

wennroy avatar wennroy commented on August 11, 2024

I just encountered the same issue here. And I found the pdfquery.py script on current Github had successfully solved this issue, but the newest release package version v0.4.3 won't work. Try to compile the newest code and it should work.

To compile the newest code

Git clone the repo and then type, (If you would like to change a version just change it in setup.py)

pip install setuptools wheel
python setup.py sdist bdist_wheel

It will give you a .whl and .tar.gz file.

To pip install it

pip install pdfquery --find-links ./

replace ./ to the directory you put your compiled .whl.

To dig a little bit deeper

Codes in v0.4.3,

# handle string prefix
if 'P' in label_format:
    page_label = label_format['P']+page_label

Codes in current github,

# handle string prefix
if 'P' in label_format:
    page_label = smart_unicode_decode(label_format['P']) + page_label

They added a smart_unicode_decode to fix the byte could not add with str value.

from pdfquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.