Open gtdrakeley opened 5 years ago
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
@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
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.
When loading a pdf via
pdf.load()
, specifically the Pathfinder 2E playtest pdf, this error is returned: