[reportlab-users] Platypus: Underlining headings

Nick Lo ingredients.com.au at gmail.com
Tue Jan 12 21:22:24 EST 2010


I'm learning Reportlab on the job (aka in a hurry) and managing to get most of what I need done except for one seemingly simple thing: I just want to underline headings. In CSS/HTML I'd be setting a style for an h1 with something like "border-bottom: 1px solid black" or I could be using an <hr>. I'm presuming I need to make a line drawing Flowable and have at this point got this much together:

class draw_line(Flowable):
def wrap(self,availWidth,availHeight):
h, w = Flowable.wrap(self,availHeight,availWidth)
return w, h

def draw(self):
self.canv.line( 1*cm, 1 * cm, PAGE_WIDTH - 1*cm, 1 * cm)

The idea I'm aiming for is to be able to just drop it in after e.g...

elements.append(Paragraph("Medical information", styles['Heading1']))
elements.append(draw_line())

...and have a line drawn underneath. Unfortunately it's not doing that yet so I was wondering if anyone could give me some pointers on doing it the right way.

Thanks,

Nick




More information about the reportlab-users mailing list