[reportlab-users] Getting the number of lines in a frame
saketh.bhamidipati at gmail.com
Mon Aug 21 09:39:11 EDT 2006
On 8/21/06, Robin Becker <robin at reportlab.com> wrote:
> Saketh Bhamidipati wrote:
> > I have a frame from which I want to get the number of lines of text.
> > Checking for newlines does not work, because the frames wrap the text. I
> > want to get the number of lines of text after the frame wraps them.
> > I hope that there is a way for me to count the number of lines of text.
> > don't want to have to measure the width of the characters and calculate
> > lines of text manually.
> > Thanks in advance,
> > Saketh
> Frames don't know anything about lines they just control space. You add
> flowables to them and they either accept the flowable or complain. You can
> choose to split the flowable or jump to the next page etc etc (at least
> that is
> what the doctemplate class attempts).
> Frames do know about space so theoretically you can ask them how big they
> and how much space they have left. At present there's no api on frames to
> that. you could just say it is
> f.y - f._y1p
> but for paragraphs that won't usually help you very much as the vertical
> used by a paragraph depends on the available width
> and the style specified leading for the paragraph as well as the text. Our
> breaking algorithm is very naive.
> Robin Becker
> reportlab-users mailing list
> reportlab-users at reportlab.com
Is there any way that I can get the text which is written to the frame with
all breaks returned as if they were newlines? That would be enough to solve
Let us say that a frame breaks a line of text. Is there some way that I can
get the frame's text with the line break returned as a newline? Then I could
count the number of newlines before breaking, count the number of newlines
after breaking, and the difference is the number of lines.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users