[reportlab-users] Platypus: Underlining headings

Robin Becker robin at reportlab.com
Wed Jan 13 04:54:06 EST 2010


On 13/01/2010 02:22, Nick Lo wrote:

> 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

.........

You can use <u>text</u> in paragraph text. I don't think we have a way to
control the line colour and thickness though.
--
Robin Becker


More information about the reportlab-users mailing list