[reportlab-users] Getting the number of lines in a frame

Robin Becker robin at reportlab.com
Mon Aug 21 12:28:34 EDT 2006


Saketh Bhamidipati wrote:
.......
>>
> 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
> my problem.
> 
> 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.
the paragraph has a wrap method which effectively breaks the lines using a 
specified width and height. So

P.wrap(availWidth,availheight)

returns the required width and height determined from the way the paragraph 
splits. Unfortunately for performance reasons the broken lines are stored in a 
fairly complex way in P.blPara.lines. So the height of the paragraph is 
len(P.blPara.lines)*P.style.leading.
-- 
Robin Becker


More information about the reportlab-users mailing list