@@ -30,6 +30,7 @@ This file is part of the iText (R) project.
30
30
import com .itextpdf .layout .layout .LayoutContext ;
31
31
import com .itextpdf .layout .layout .LayoutResult ;
32
32
import com .itextpdf .layout .properties .ContinuousContainer ;
33
+ import com .itextpdf .layout .properties .OverflowPropertyValue ;
33
34
import com .itextpdf .layout .properties .Property ;
34
35
import com .itextpdf .layout .properties .UnitValue ;
35
36
@@ -75,7 +76,7 @@ public final void setHeightCalculator(ColumnHeightCalculator heightCalculator) {
75
76
@ Override
76
77
public LayoutResult layout (LayoutContext layoutContext ) {
77
78
this .setProperty (Property .TREAT_AS_CONTINUOUS_CONTAINER , Boolean .TRUE );
78
-
79
+ setOverflowForAllChildren ( this );
79
80
Rectangle actualBBox = layoutContext .getArea ().getBBox ().clone ();
80
81
float originalWidth = actualBBox .getWidth ();
81
82
applyWidth (actualBBox , originalWidth );
@@ -170,6 +171,16 @@ protected AbstractRenderer createOverflowRenderer(IRenderer overflowedContentRen
170
171
return overflowRenderer ;
171
172
}
172
173
174
+ private void setOverflowForAllChildren (IRenderer renderer ) {
175
+ if (renderer == null ) {
176
+ return ;
177
+ }
178
+ renderer .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
179
+ for (IRenderer child : renderer .getChildRenderers ()) {
180
+ setOverflowForAllChildren (child );
181
+ }
182
+ }
183
+
173
184
private void applyWidth (Rectangle parentBbox , float originalWidth ) {
174
185
final Float blockWidth = retrieveWidth (originalWidth );
175
186
if (blockWidth != null ) {
@@ -425,7 +436,14 @@ public Float getAdditionalHeightOfEachColumn(MulticolRenderer renderer, Multicol
425
436
}
426
437
LayoutResult overflowResult = result .getOverflowRenderer ().layout (
427
438
new LayoutContext (new LayoutArea (1 , new Rectangle (renderer .columnWidth , INF ))));
428
- height = overflowResult .getOccupiedArea ().getBBox ().getHeight () / maxRelayoutCount ;
439
+ float overflowHeight = overflowResult .getOccupiedArea ().getBBox ().getHeight ();
440
+ if (result .getSplitRenderers ().isEmpty ()) {
441
+ // In case when first child of content bigger or wider than column and in first layout NOTHING is
442
+ // returned. In that case content again layouted in infinity area without keeping in mind that some
443
+ // approximateHeight already exist.
444
+ overflowHeight -= renderer .approximateHeight ;
445
+ }
446
+ height = overflowHeight / maxRelayoutCount ;
429
447
return height ;
430
448
}
431
449
0 commit comments