[reportlab-users] keeptogether

Ulrich Schreiner reportlab-users@reportlab.com
Thu, 05 Feb 2004 22:18:20 +0100


hi,

i use the "KeepTogether" and it does not really work. first i tried to 
have a "KeepTogether" with two flowables inside. the first one was again 
a "KeepTogether" (with two paragraphs inside) and the other one was a 
paragraph. well ... the output was not what i wanted. hard to describe, 
sorry. but the "KeepTogether" flowables did not span the correct area. 
it looks like that after nested "KeepTogether" blocks there is _always_ 
a pagebreak!

so i made no nested "KeepTogethers". but now i have circumstances where 
i get a "LayoutError". the problem here is that i use styles with a 
"spaceAfter" setting.

as you can see in the "_add" method of the "Frame" class the calculation 
of the required space uses the "spaceBefore" setting but not the 
"spaceAfter".

BUT: at the end of the method the current y-position is decreased by the 
value of "spaceAfter" and sometimes it happens that the value of "y" now 
is negative! the "_add" method itself returns 1 so it signals not to 
make a framebreak and now .... the nightmare starts :-). the next 
flowable which should be layouted crashes with a exception.

i changed my styles not to use "spaceAfter" anymore. now i work with 
"spaceBefore" (and a few more styles) and everything works. but it would 
be a good idea to rework the code.

good night!
</usc>