[reportlab-users] Platypus + dividing lines ?

Tim Roberts timr at probo.com
Fri Mar 21 18:13:17 EDT 2008


reportlab at richardshea.fastmail.fm wrote:

> Thanks for that. Can I ask another, related question ?

>

> I also want thin lines to appear between two paragraphs at some points

> in the document (so the line would be the width of a column).

>

> I'm using 'addFromList' based upon a list of paragraphs to build the

> story and so I'm not sure how I can do this (I suppose I could make the

> line an image but that seems a bit clunky). I can't, as far as I can

> see, use absolute coordinates because I don't know where the paragraph

> break is going to be rendered.

>

> I'm sure there is a way - could anyone tell ?

>


What I did was write myself a flowable that I could add to the story
just like another paragraph, whose sole function was to draw a
horizontal line out to the column boundaries. I haven't used this in
about 5 years, but maybe you can adapt it:

class HorizontalRule(Flowable):
def __init__(self, width=3, strokecolor=black):
self.width = width
self.strokecolor = strokecolor
def wrap(self, availWidth, availHeight):
self.availWidth = availWidth
return (availWidth, self.width + 2)
def draw(self):
canvas = self.canv
canvas.setLineWidth(self.width)
canvas.setStrokeColor(self.strokecolor)
p = canvas.beginPath()
p.moveTo(0, 1)
p.lineTo(self.availWidth, 1)
p.close()
canvas.drawPath( p )

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list