You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to parse a PDF that contains Chinese characters.
The text is extracted okay, but when I try to access fonts, I get the following error:
>>>box.get_font_name() # Assume the box is extracted from some page, this box contains Chinese charactersTraceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"<PATH>/lib/python3.7/site-packages/poppler/utilities.py", line90, inwrappedreturnfct(*args, **kwargs)
File"<PATH>/lib/python3.7/site-packages/poppler/page.py", line64, inget_font_namereturnself._text_box.get_font_name(i)
UnicodeDecodeError: 'utf-8'codeccan'tdecodebyte0xbainposition7: invalidstartbyte
Trying to iterate fonts through the document itself results in the same error.
Environment:
Python 3.7.4
Poppler 21.12.0 (Compiled from source).
Happens on both Mac and Ubuntu.
I have seen other poppler bindings, such as this one that handles those errors (by using the replace keyword for decoding the string), but unfortunately it uses deprecated internal APIs and cannot be used with a newer version of poppler (even when trying to build from source).
If there was somehow a way to supply the required encoding or even suppress/ignore those errors, it would be very benficial.
I have seen another comment on another ticket that says we can request to expose the encoding/decoding in the cpp backend.
The text was updated successfully, but these errors were encountered:
poppler-cpp gives the font name as std::string, not as ustring. Therefore, I think the bug must be resolved upstream, unless we used some heuristics to guess the encoding, which would probably be fragile.
I'm trying to parse a PDF that contains Chinese characters.
The text is extracted okay, but when I try to access fonts, I get the following error:
Trying to iterate fonts through the document itself results in the same error.
Environment:
Python 3.7.4
Poppler 21.12.0 (Compiled from source).
Happens on both Mac and Ubuntu.
I have seen other poppler bindings, such as this one that handles those errors (by using the
replace
keyword for decoding the string), but unfortunately it uses deprecated internal APIs and cannot be used with a newer version of poppler (even when trying to build from source).If there was somehow a way to supply the required encoding or even suppress/ignore those errors, it would be very benficial.
I have seen another comment on another ticket that says we can request to expose the encoding/decoding in the cpp backend.
The text was updated successfully, but these errors were encountered: