[reportlab-users] Platypus + dividing lines ?
    reportlab at richardshea.fastmail.fm 
    reportlab at richardshea.fastmail.fm
       
    Sat Mar 22 04:57:51 EDT 2008
    
    
  
On Fri, 21 Mar 2008 15:13:17 -0700, "Tim Roberts" <timr at probo.com> said:
> 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 )
> 
That's really great, thank you very much indeed - I appreciate it. It
looks like just what I was after but without reading your code it would
have taken me a long time to figure out how to do it ! And thanks again
for your earlier answer.
Regards
Richard.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The Cuba Group
PO Box 1864
Wellington
New Zealand
PH +64 4 496 5205
MO +64 21 296 6839 
FX +64 4 496 5209
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    
More information about the reportlab-users
mailing list