[reportlab-users] flowables.KeepTogether.split() adding unnecessary FrameBreak

Robin Becker robin at reportlab.com
Mon Feb 22 08:32:17 EST 2010


On 22/02/2010 13:08, Roberto Alsina wrote:

> On Monday 22 February 2010 09:54:53 Robin Becker wrote:

>> I think what's happening here is that the keepWithNext is creating a

>> combined flowable which is larger than the entire page or frame in height

>> ie KeepTogether([heading,Table([....])]). Effectively that forces the

>> frame add to cause an attempt to split on the next page. Unfortunately I

>> don't think our current methodology has enough information to make a

>> decent decision. A better way to keep a heading with another flowable is

>> to use some kind of conditional page throw

>

> I have this problem in several places in rstpdf, but I don't know anything

> about conditional page throws... could you point me in the right direction?

> Maybe some code I can copy that does more or less the same as that

> keeptogether?

...........
In flowables.py there's a flowable class called CondPageBreak. It's misnamed
because it's actually a conditional frame break, but the same principle applies
anyhow.


Suppose you'd like to keep heading H together with table T. What's really
required is that assuming T splits H+spacing+T[0] fits on the current page.
Assume that H+spacing+T[0] needs 1.5 inches then you add

CondPageBreak(1.5*72)
H
T

to the story; if when the conditional break gets wrapped there's less than 1.5
inches left then the page break is invoked else the break just vanishes.
--
Robin Becker


More information about the reportlab-users mailing list