[reportlab-users] KeepTogether limit

Robin Becker robin at reportlab.com
Mon Mar 26 11:02:44 EDT 2007

David S. wrote:

> Is there a way to have KeepTogether NOT keep together when a flowable is bigger

> than some size? I tried to use maxHeight but without success.


> Thanks,

> David S.

....... I don't think it has right now, but the logic in there is perhaps not
particularly simple.

Basically the contents should be wrapped only once, then when we come to draw
the contents we either have enough space or are asked to split. In the split
method we always return the contents list possibly modified.

C0 = self._H>aH and (not self._maxHeight or aH>self._maxHeight)
ie content height >available height and the maxHeight isn't binding

C1 = self._H0>aH
ie the initial bit of contents is too large

if C0 then we attempt to move to the next frame before doing the rest of the
layout. Otherwise if C1 is true we insert an extra empty flowable in the list to
allow the large item to be re-split next time around. In all other cases the
contents list is returned as is. The C0 condition is probably a bit fake, but
it's not to do with switching off the keepTogether behaviour. To do that we'd
need to do something like

if self._H>x:
C1 = True
C0 = False

we need C1 = True so the outer algorithm can think it's making some progress (we
insert a Null flowable into the stream).
Robin Becker

More information about the reportlab-users mailing list