Encoding UTF-8 instead of PDFDoc
Koki Nomura <[email protected]>
| Newsgroups | gmane.comp.python.reportlab.user |
|---|---|
| Message-ID | <CAE6MiFY5U-LyEd0hVSoxFrD1HRo_7HHhSd2_OSFUjFbNoo-CnQ@mail.gmail.com> |
Hi,
pdfdocEnc() in pdfdoc.py raises a UnicodeEncodeError as below when I
process a PDF file with Unicode characters. I'm running my script on Python
3.6.0.
UnicodeEncodeError: 'charmap' codec can't encode character '\x00' in
position 11: character maps to <undefined>
This error disappears when I change the encoding from extpdfdoc to utf-8 in
this block of code.
if isPy3:
def pdfdocEnc(x):
return x.encode('extpdfdoc') if isinstance(x,str) else x
While I don't fully understand 'extpdfdoc' encoding, can we change this
encoding to utf-8 as PDF specifications allow to use Unicode as well as
PDFDocEncoding?
Thanks,
Koki