[reportlab-users] Encoding UTF-8 instead of PDFDoc

Koki Nomura nomura at agic.cc
Wed Mar 1 00:05:20 EST 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20170301/3d263e30/attachment.html>


More information about the reportlab-users mailing list