[reportlab-users] Special characters in paragraphs

Dick Kniep dick at kniep.nl
Wed Dec 14 04:43:20 EST 2005


Hi list,

We have a problem with special characters used in paragraphs in tables. I get the following error. 

  File "/home/dick/CVix/CVix/src/GenReportLab.py", line 319, in BuildReport
    self.PdfOutput(lvl, content, h, tabStyle, int(self.fontSize)+1 )
  File "/home/dick/CVix/CVix/src/GenReportLab.py", line 344, in PdfOutput
    r.append(Paragraph(fld,parStyle))
  File "/usr/lib/python2.4/site-packages/reportlab/platypus/paragraph.py", line 378, in __init__
    self._setup(text, style, bulletText, frags, cleanBlockQuotedText)
  File "/usr/lib/python2.4/site-packages/reportlab/platypus/paragraph.py", line 403, in _setup
    raise "xml parser error (%s) in paragraph beginning\n'%s'"\
xml parser error (; missing in entityref) in paragraph beginning
'Den Besten&Sloof'

Note the '&' in the text which causes the crash.

The code to set the contents of the paragraph is:

tabStyle.add('ALIGN',(n,l),(n,l),'LEFT')
r.append(Paragraph(fld,parStyle))

So the paragraph is added to a reportlab table that is eventually output to a PDF.

I tried :
r.append(Paragraph(unicode(fld),parStyle)). This gives me the same exceptions, however, it complains about a unicode string in the exception.
I tried:
r.append(Paragraph(fld.encode('utf-8'),parStyle))
Same error
So if anyone has a simple solution to this problem.
Cheers,
Dick Kniep



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://two.pairlist.net/pipermail/reportlab-users/attachments/20051214/0aa46935/attachment.html


More information about the reportlab-users mailing list