[reportlab-users] Preformatted() with bullets

Marius Gedminas marius at gedmin.as
Tue Jul 14 17:21:46 EDT 2009

To get bulleted text we use

bullet_text = ParagraphStyle('bullet_text', parent=normal)
bullet_text.leftIndent = 36
bullet_text.spaceBefore = 3
bullet_text.bulletIndent = 24
bullet_text.is_bullet = 1
# ReportLab 2.0 wants UTF-8 here, ReportLab 1.20 wanted Windows-1252
bullet_text.bullet_char = u'\u2022'.encode('UTF-8')


and it works fine. (I admit I've no clue why I have to explicitly pass
bulletText to the Paragraph when it's already specified in the style.
Maybe I should go read the documentation again. In the mean time it

Now at some point we needed to change the style of the bulleted
paragraphs to show preformatted text (monospaced font, keeping newlines
and everything). Unfortunately, if you just substitute Preformatted
for Paragraph in the code above, you get no bullets drawn at all.

I've wanted to post this fix in proper patch form with tests and
everything for *years* now, but I never seem to find the time. So here
is the workaround we currently use, in raw form:

from reportlab.platypus.flowables import Preformatted as _Preformatted

class Preformatted(_Preformatted):

def draw(self):
offset = self.style.firstLineIndent
cur_y = self.height - self.style.fontSize
if self.bulletText <> None:
offset = _drawBullet(self.canv, offset, cur_y, self.bulletText,

I'll keep trying to find some time to do it properly (patch with tests),
but I don't expect it to happen soon. :(

Marius Gedminas
He who sacrifices functionality for ease of use
Loses both and deserves neither
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20090715/05f083c8/attachment.pgp>

More information about the reportlab-users mailing list