[reportlab-users] Unicode support in platypus.para Module?

Dirk Holtwick holtwick at spirito.de
Tue Jul 4 09:40:32 EDT 2006

Hi Robin,

seems that you have fixed the problem yesterday in the SVN version of
reportlab. Works also fine with my example script, that now comes a
little to late ;-)

Thanks Robin.


Robin Becker schrieb:
> Dirk Holtwick wrote:
>> Hi,
>> here once again my yet unanswered question. Is it possible, that the
>> para.py module has no Unicode support? Will it be added in future?
>> Bye,
>> Yours Dirk
>> Dirk Holtwick schrieb:
>>> Hello,
>>> at first it is great that now Unicode is widely supported in the
>>> Reportlab Toolkit. Thanks.
>>> Now to my problem: I use the platypus.para module for generating pages.
>>> If I now use an opcode that is coded in UTF-8 or Unicode I get
>>> exceptions. The easiest way to reproduce this, is to encode a string in
>>> the 'test_program' in the module itself.
>>> To fix an error I got with my program I changed the method "runOpCodes"
>>> in line 703 of the recent version in the repository to:
>>>                     opcode = opcode.encode("latin1","ignore")
>>>                     text = escape(opcode)
>>> Then it works fine for Postscript and TTF fonts. Any idea?
>>> Bye, Dirk
> .......
> Dirk, I'm not an expert on the para code, but the problem here is really
> about the fonts. For the other kind of paragraph we have quite a complex
> mechanism for converting unicode/utf8 into the pdf text that's required.
> At the very least we need to know what font is being used at the text
> issuing point. I can get that using the fontName variable (I believe) so
> then the same kind of string processing can be used to get the text
> correctly encoded.
> I don't have time right now, but prod me at the weekend with a breaking
> example eg 'hello world' with some wrong behaviour and I'll have a go at
> fixing this.


Dirk Holtwick


spirito GmbH
Dirk Holtwick
Grünstraße 6
D-47051 Duisburg

fon:   +49-203-3187777
fax:   +49-203-34666896
mbx:   holtwick at spirito.de
web:   http://www.spirito.de
skype: holtwick

GnuPG fingerprint (http://www.gnupg.org)
A5A1 54E1 C82E 02AD 4804  0547 66F4 3FB0 C790 EBAB

Wichtiger Hinweis:

E-Mails können leicht verfälscht oder unter fremdem Namen erstellt
werden. Zu Ihrer und unserer Sicherheit schließen wir die rechtliche
Verbindlichkeit des vorstehenden Inhaltes aus, mithin dient der
Versand von E-Mails ausschließlich dem Informationsaustausch.
Bitte  senden Sie in Ihrem eigenen Interesse keine E-Mails in
fristgebundenen Sachen.
-------------- next part --------------
# -*- coding: ISO-8859-1 -*-

from reportlab.platypus import *
from reportlab.lib.styles import *
from reportlab.rl_config import *
from reportlab.lib.units import *
from reportlab.platypus.para import *
import os

styles = getSampleStyleSheet()
text1 = unicode("Über den Wolken", "latin1")
text2 = unicode("Über den Wolken", "latin1").encode("utf8")

program = [
    ("align", 2),
    ("size", 20),
    ("size", 10),
    #('nextLine', 0),

def test():
    doc = SimpleDocTemplate("test.pdf")
    story = []
    p = Para(styles["Normal"], parsedText="", bulletText=None, state=None)
    p.program = program

if __name__=="__main__":
    os.system("start test.pdf")

More information about the reportlab-users mailing list