@@ -45,6 +45,7 @@ This file is part of the iText (R) project.
45
45
46
46
import com .itextpdf .io .LogMessageConstant ;
47
47
import com .itextpdf .io .font .constants .StandardFonts ;
48
+ import com .itextpdf .kernel .colors .Color ;
48
49
import com .itextpdf .kernel .colors .ColorConstants ;
49
50
import com .itextpdf .kernel .font .PdfFontFactory ;
50
51
import com .itextpdf .kernel .geom .PageSize ;
@@ -97,6 +98,7 @@ public class KeepTogetherTest extends ExtendedITextTest {
97
98
private static final String MEDIUM_TEXT = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr"
98
99
+ " sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
99
100
+ " At vero eos et accusam et justo duo dolores et ea rebum.\n " ;
101
+ private static final String SMALL_TEXT = "Short text" ;
100
102
101
103
102
104
@ BeforeClass
@@ -1126,6 +1128,43 @@ public void contentOverlappingDivKeepTogetherInRectTest() throws IOException, In
1126
1128
Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder ));
1127
1129
}
1128
1130
1131
+ @ Test
1132
+ //TODO: DEVSIX-4720 (invalid positioning of child element)
1133
+ public void keepTogetherInDivWithKidsFloatTest () throws IOException , InterruptedException {
1134
+ String filename = "keepTogetherInDivWithKidsFloat.pdf" ;
1135
+ String outFile = destinationFolder + filename ;
1136
+ String cmpFileName = sourceFolder + "cmp_" + filename ;
1137
+
1138
+ try (Document doc = new Document (new PdfDocument (new PdfWriter (outFile )))) {
1139
+ doc .getPdfDocument ().addNewPage (PageSize .A5 .rotate ());
1140
+
1141
+ Div main = new Div ().setKeepTogether (true );
1142
+ main .setBackgroundColor (ColorConstants .LIGHT_GRAY );
1143
+
1144
+ Div child1 = createChildDivWithText (main , SMALL_TEXT );
1145
+ child1
1146
+ .setBackgroundColor (ColorConstants .YELLOW )
1147
+ .setWidth (UnitValue .createPercentValue (30 ))
1148
+ .setProperty (Property .FLOAT , FloatPropertyValue .LEFT );
1149
+
1150
+ Div child2 = createChildDivWithText (main , BIG_TEXT );
1151
+ child2
1152
+ .setBackgroundColor (ColorConstants .GREEN )
1153
+ .setWidth (UnitValue .createPercentValue (70 ))
1154
+ .setProperty (Property .FLOAT , FloatPropertyValue .LEFT );
1155
+
1156
+ Div child3 = createChildDivWithText (main , "Test" );
1157
+ child3 .setBackgroundColor (ColorConstants .ORANGE );
1158
+
1159
+ Div child4 = createChildDivWithText (main , MEDIUM_TEXT );
1160
+ child4 .setBackgroundColor (ColorConstants .ORANGE );
1161
+
1162
+ doc .add (main );
1163
+ }
1164
+
1165
+ Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder ));
1166
+ }
1167
+
1129
1168
private Div createChildDivWithText (Div parent , String text ) {
1130
1169
Div child = new Div ();
1131
1170
if (text != null ) {
0 commit comments