23 January 2009

Unicode reports with ReportLab

Yesterday I've just figured out that OpenERP's default report engine is still unable to create PDF reports with full unicode character support. Only the characters present in the Latin1 encoding are allowed.
This is all because the PDFs are genereated with the old standard Type1 fonts that have only Latin1 characters. The solution is to use TrueType fonts that have proper unicode support.
After browsing the forums and the net for some time I created a blueprint and a wikipage with a possible solution.
bug: https://bugs.launchpad.net/bugs/319595

4 comments:

  1. Hi Dukai thank you. I have tried your fix for the unicode report however I got this problem when start the server.
    [2009-02-27 17:43:33,441] INFO:objects:initialising distributed objects services
    Traceback (most recent call last):
    File "./openerp-server.py", line 93, in module>
    import report
    File "/usr/lib/python2.5/site-packages/openerp-server/report/__init__.py", line 23, in module>
    import interface
    File "/usr/lib/python2.5/site-packages/openerp-server/report/interface.py", line 36, in module>
    import render
    File "/usr/lib/python2.5/site-packages/openerp-server/report/render/__init__.py", line 24, in module>
    from rml import rml, rml2html
    File "/usr/lib/python2.5/site-packages/openerp-server/report/render/rml.py", line 24, in module>
    import rml2pdf
    File "/usr/lib/python2.5/site-packages/openerp-server/report/render/rml2pdf/__init__.py", line 53
    'DejaVuSans', 'DejaVuSans.ttf',enc))
    ^
    SyntaxError: invalid syntax
    I use openerp 5.0.0.3 Could you please give me some advice on how to fix this. Thank you.

    ReplyDelete
  2. It should be like pdfmetrics.registerFont(TTFont('DejaVuSans', 'DejaVuSans.ttf',enc))
    in one line not just
    'DejaVuSans', 'DejaVuSans.ttf',enc))

    ReplyDelete
  3. Thank you Dukai. It works like a charm now. May be you could add the missing pdfmetrics.registerFont(TTFont( into the wiki page. I could't see them, or maybe that's just my case :D. Thank you very much.

    ReplyDelete
  4. Thanx for this fix!

    We were trying to print reports in ukrainian without success.

    ReplyDelete

Note: Only a member of this blog may post a comment.