[reportlab-users] Platypus + dividing lines ?

Robin Becker robin at reportlab.com
Sat Mar 22 05:38:29 EDT 2008


Tim Roberts wrote:

> 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):

....... 1)

> p.close()

> canvas.drawPath( p )

>


modern reportlab.platypus.flowables has an HRFlowable that allows this
sort of functionality it looks like this

class HRFlowable(Flowable):
'''Like the hr tag'''
def __init__(self,
width="80%",
thickness=1,
lineCap='round',
color=lightgrey,
spaceBefore=1, spaceAfter=1,
hAlign='CENTER', vAlign='BOTTOM',
dash=None):

--
Robin Becker


More information about the reportlab-users mailing list