[reportlab-users] Platypus idea "splitting preferences"

Henning von Bargen H.vonBargen at t-p.com
Fri Jan 15 03:59:12 EST 2010


Roberto Alsina wrote:

> I am thinking there are flowables that would prefer not to be split if

> possible, for example small literal blocks (say, a code fragment), but *if

> needed* can be split anyway (for example if they are over a page long, or

> would leave a half-empty page if not split).



> Would reportlab be interested in this kind of functionality? I am thinking of

> adding a property to the flowables describing this and hacking the place where

> frames consume flowables so it's taken into account.



> Any suggestions about how the property should look like, or how it should be

> handled are welcome, since I am still pretty fuzzy on what I really mean ;-)


There are several cases where this or something similar would be useful:

a) Table cells (as Andy mentioned)
cannot be split right now, because the table splitting algorithm
does not support it.

b) Tables
Other programs (say, Oracle Reports) support a "minimum widow records"
property for tables. That means, only start the table on the current
page, if at least the first N rows fit. Otherwise push the table to
the next page. This is often useful, at least if the rows height are
similar. That way you can avoid wasting space (in contrast to
allow_splitting = False for the whole table); it also works if the
table is longer than one page, and if N is set to the number of rows,
it has the same effect as allow_splitting = False.

c) List
I could also imagine a new flowable "List" - which is logically a table
with just one column (a mixture of KeepTogether and Table). It should
support specifying a goal for maximum_space_wasted and a minwidow_rows
property, and try to reach this goal as follows:
Take min_widow_rows N into account.
If the first N rows don't fit,
Push the whole List to the next page.
For the rest of the rows:
If the current_row doesn't fit:
If space left on current page > maximum_space_wasted:
Try to split the current_row.
If splitting was possible (part1, part2):
Render part1 to current page,
Push List(part2 + remaining rows) to the next page.
Else:
Push List(current_row + remaining_rows) to next page.
Else:
Push List(remaining rows) to the next page
Whenever a List is pushed to the next page, set min_widow_rows = 0.

Splitting a List is a lot easier than a Table, because it's not
necessary (I think) to support background colours, grid lines etc,
and splitting a row means only to split the one and only column.

Note:
I'm not sure if the meaning of "widow" here is what it's called in RL.
I mean: Only start the flowable on the current page, if at least the
first N rows fit - otherwise push it to the next page.

Henning




More information about the reportlab-users mailing list