Comments (3)
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.
@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.
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)
- Can't get coordinates.
- Pseudo classes not working
- How does pdfquery determine the index?
- can load the pages I need HOT 1
- ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters HOT 1
- PdfQuery | .extract problem
- loading file with filecache AttributeError: 'NoneType' object has no attribute 'writestr' HOT 1
- windows only: pdfquery is locking the opended pdf-file HOT 1
- Extract all words with their coordinates.
- cache collision HOT 1
- can't concat str to bytes EASY FIX -- please update! HOT 3
- recommend you use pdfminer rather than pdfquery HOT 1
- Not able to detect horizontal lines properly.
- Coordinates to locator
- Is this project still alive? HOT 3
- Python 2 dependency problem: pyquery
- Support for password protected pdf files
- AttributeError: module 'pdfquery' has no attribute 'PDFQuery'
- TypeError: 'PDFObjRef' object is not subscriptable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfquery.