[reportlab-users] Line numbers in Platypus

Jonathan Claggett jonathan at claggett.org
Wed Mar 19 13:15:49 EDT 2008


On Wed, Mar 19, 2008 at 12:08 PM, Robin Becker <robin at reportlab.com> wrote:


> Jonathan Claggett wrote:

> > Hello,

> >

> > I've just recently become aware of the RL toolkit (thus my first post to

> the

> > list :-) and I'm evaluating it for use in generating legal bills* for a

> > model UN youth organization.

> >

> > One of the requirements of these bills is that the body has line numbers

> and

> > I'm not sure how or even if line numbering can occur with variable

> height

> > objects like the Paragraph. My initial reaction after reading the user

> > manual is 'probably'.

> >

> > At a hand waving level, I think I can subclass the BaseDocTemplate to

> create

> > an afterFlowable method which determines how many lines a Paragraph or

> other

> > flowable has used (using the wrap method?) which I then use to draw a

> > sequence (maintained by the sequencer module) of line numbers in a

> separate

> > frame down the left hand margin.

> >

> are you talking physical lines or total lines since the start etc etc.



I need to print a number in the left hand margin showing physical lines of
text. The example I linked to shows a sample with 23 lines not including
various header lines.



> Certainly it should be possible to figure out at wrap time how many lines

> a paragraph has

> (or even at draw time) and use that to do something elsewhere on the same

> canvas.

>


I think I found it. I was digging into the flowable paragraph object passed
to the afterFlowable method and there is a container (I think it is an
ABag?) with a lines attribute that looks like the physical lines of the
paragraph. So len(flowable.blPara.lines) will return the number of physical
lines for a given paragraph. Now, I just need to figure out how to make my
own frame for the line numbers :-)



>

> > Does this above approach sound reasonable? Maybe Platypus has a line

> > numbering feature already and I missed it? Perhaps someone has already

> > created a line numbering document template that I could use?

> >

> > Thanks for any help you can provide.

> >

> > Regards,

> > Jonathan

> >

> > * e.g., http://jonathan.claggett.googlepages.com/sample-bill.pdf

> --

> Robin Becker



Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20080319/4bc29a0c/attachment.htm>


More information about the reportlab-users mailing list