[reportlab-users] Paragraph text with &

Juha Ruotsalainen kontza at gmail.com
Mon Feb 5 15:32:09 EST 2007


Hi there,

On 2/3/07, Robin Becker <robin at reportlab.com> wrote:

> If you really want the text "<subject>Jack, Jim &amp; Jill</subject>" to

> appear in a pdf document using Paragraph then you need to actually have

> the text

>

> &lt;subject&gt;Jack, Jim &amp;amp; Jill&lt;/subject&gt;

>

> you can do this in python with

>

> >>> from xml.sax.saxutils import escape

> >>> print escape("<subject>Jack, Jim &amp; Jill</subject>")

> &lt;subject&gt;Jack, Jim &amp;amp; Jill&lt;/subject&gt;

> >>>

>

This did the trick! My main concern was to have ampersands printed
into the PDF. Thanks for pointing out the escape :-)

I remember using something 'escapish' years ago, back when I was still
using Perl. No wonder I didn't find a solution in Python's docs,
because I was looking for 'quote', or something like that, not
'escape'.

Cheers,
--
jussi


More information about the reportlab-users mailing list