[reportlab-users] < in Paragraph

Chris Crownhart ccro at kaivo.com
Thu May 4 16:32:07 EDT 2006

I have a question regarding <, > and & usage in a Paragraph.

My code is simply this:

         val = string.replace(val, '<', '&lt;')
         val = Paragraph(str(val),self.StyleSheet['Normal'])

My val is 'Average temp <90.'  And I need the text to wrap.

If I leave the above string.replace in the code, I get back a PDF with 
&lt; in it.  If I comment it out, I get this traceback and error:

Traceback (most recent call last):
  File "/usr/local/zope/Extensions/report_one_note.py", line 262, in rlzope
    content = str(MyPDFDoc(self, filename, ids))
  File "/usr/local/zope/Extensions/report_one_note.py", line 208, in __init__
    val = Paragraph(str(val),self.StyleSheet['Normal'])
  File "/usr/local/python2.3.4/lib/python2.3/site-packages/reportlab/platypus/paragraph.py", line 378, in __init__
    self._setup(text, style, bulletText, frags, cleanBlockQuotedText)
  File "/usr/local/python2.3.4/lib/python2.3/site-packages/reportlab/platypus/paragraph.py", line 403, in _setup
    raise "xml parser error (%s) in paragraph beginning\n'%s'"\
xml parser error (bogus < or &) in paragraph beginning
'Average temp <90.'

More information about the reportlab-users mailing list