[reportlab-users] "setfont" tag in RML seems not to work propelry
Ulrich Weber
reportlab-users@reportlab.com
Mon, 19 Jul 2004 11:59:04 +0200
When using the setfont tag in RML with a font name different from
"Helvetica" or "Times-Roman" I get a python exception as shown in the
following example:
RML-Code:
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
<!DOCTYPE document SYSTEM "rml_1_0.dtd">
<document filename="dummy.pdf">
<template pageSize="(21cm, 29.7cm)" leftMargin="2cm" rightMargin="2cm"
topMargin="2.5cm" bottomMargin="2.5cm">
<pageTemplate id="main">
<pageGraphics>
<setFont name="Helvetica-Bold" size="14"/>
<drawString x="2cm" y="28.0cm">test</drawString>
</pageGraphics>
<frame id="body" x1="1.8cm" y1="2.5cm" width="17.4cm" height="24.7cm"/>
</pageTemplate>
</template>
<stylesheet>
</stylesheet>
<story>
<para>This is the "story". This is the part of the RML document where
your text is placed.</para>
</story>
</document>
Resulting python message:
Traceback (most recent call last):
File "D:\Program
Files\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
File "D:\AR_Tool\AR_Tool_V9.1\AR_Tool\Script1.py", line 27, in ?
x = parseString(rml)
File "trml2pdf\trml2pdf.py", line 518, in parseString
File "trml2pdf\trml2pdf.py", line 148, in render
File "trml2pdf\trml2pdf.py", line 507, in render
File "D:\Program
Files\Python23\lib\site-packages\reportlab\platypus\doctemplate.py", line
650, in build
self._endBuild()
File "D:\Program
Files\Python23\lib\site-packages\reportlab\platypus\doctemplate.py", line
607, in _endBuild
if getattr(self,'_doSave',1): self.canv.save()
File "D:\Program
Files\Python23\lib\site-packages\reportlab\pdfgen\canvas.py", line 847, in
save
self._doc.SaveToFile(self._filename, self)
File "D:\Program
Files\Python23\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 234, in
SaveToFile
f.write(self.GetPDFData(canvas))
File "D:\Program
Files\Python23\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 256, in
GetPDFData
return self.format()
File "D:\Program
Files\Python23\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 413, in
format
return File.format(self)
File "D:\Program
Files\Python23\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 770, in
format
return string.join(self.strings, "")
File "D:\Program Files\Python23\Lib\string.py", line 135, in join
return sep.join(words)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x93 in position 11:
ordinal not in range(128)
As stated above, font names "Helvetica" and "Times-Roman" work fine, all
other font names don't work.
I am using Python 2.3; may this cause the problem ?
I am looking forward to your advice!
Ulrich Weber