@@ -22,14 +22,13 @@ This file is part of the iText (R) project.
22
22
*/
23
23
package com .itextpdf .layout .element ;
24
24
25
- import com .itextpdf .io .logs .IoLogMessageConstant ;
26
25
import com .itextpdf .kernel .colors .ColorConstants ;
27
26
import com .itextpdf .kernel .pdf .PdfDocument ;
28
27
import com .itextpdf .kernel .pdf .PdfWriter ;
29
28
import com .itextpdf .kernel .utils .CompareTool ;
30
29
import com .itextpdf .layout .Document ;
31
30
import com .itextpdf .layout .borders .SolidBorder ;
32
- import com .itextpdf .layout .exceptions . LayoutExceptionMessageConstant ;
31
+ import com .itextpdf .layout .properties . BoxSizingPropertyValue ;
33
32
import com .itextpdf .layout .properties .Property ;
34
33
import com .itextpdf .layout .properties .UnitValue ;
35
34
import com .itextpdf .layout .properties .grid .AutoRepeatValue ;
@@ -45,8 +44,6 @@ This file is part of the iText (R) project.
45
44
import com .itextpdf .layout .properties .grid .PointValue ;
46
45
import com .itextpdf .layout .properties .grid .TemplateValue ;
47
46
import com .itextpdf .test .ExtendedITextTest ;
48
- import com .itextpdf .test .annotations .LogMessage ;
49
- import com .itextpdf .test .annotations .LogMessages ;
50
47
import com .itextpdf .test .annotations .type .IntegrationTest ;
51
48
52
49
import java .io .IOException ;
@@ -969,4 +966,110 @@ public void marginsCollapsingIssueTest() throws IOException, InterruptedExceptio
969
966
}
970
967
Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
971
968
}
969
+
970
+ @ Test
971
+ public void splitPageTest () throws IOException , InterruptedException {
972
+ String filename = DESTINATION_FOLDER + "splitPageTest.pdf" ;
973
+ String cmpName = SOURCE_FOLDER + "cmp_splitPageTest.pdf" ;
974
+ java .util .List <TemplateValue > columnsTemplate = new ArrayList <>();
975
+ columnsTemplate .add (new AutoRepeatValue (true , Arrays .asList ((GridValue ) new PointValue (200 ))));
976
+
977
+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
978
+ GridContainer grid = new GridContainer ();
979
+ grid .setWidth (420 );
980
+ grid .setBorder (new SolidBorder (20 ));
981
+ grid .setPadding (20 );
982
+ grid .setMargin (20 );
983
+ grid .setProperty (Property .GRID_TEMPLATE_COLUMNS , columnsTemplate );
984
+ grid .setProperty (Property .COLUMN_GAP , 20.0f );
985
+ grid .add (new Paragraph ("One" ).setBackgroundColor (ColorConstants .CYAN ));
986
+ grid .add (new Paragraph ("Two" ).setBackgroundColor (ColorConstants .CYAN ));
987
+ grid .add (new Paragraph ("Tree" ).setBackgroundColor (ColorConstants .CYAN ));
988
+ grid .add (new Paragraph ("Four" ).setBackgroundColor (ColorConstants .CYAN ));
989
+ grid .add (new Paragraph ("Five" ).setBackgroundColor (ColorConstants .CYAN ));
990
+ grid .add (new Paragraph ("Six" ).setBackgroundColor (ColorConstants .CYAN ));
991
+ grid .add (new Paragraph ("Seven" ).setBackgroundColor (ColorConstants .CYAN ));
992
+ grid .add (new Paragraph ("Eight" ).setBackgroundColor (ColorConstants .CYAN ));
993
+ grid .add (new Paragraph ("Nine" ).setBackgroundColor (ColorConstants .CYAN ));
994
+
995
+ Div emptyDiv = new Div ();
996
+ emptyDiv .setHeight (640 );
997
+ emptyDiv .setBackgroundColor (ColorConstants .LIGHT_GRAY );
998
+ document .add (emptyDiv );
999
+ document .add (grid );
1000
+ }
1001
+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
1002
+ }
1003
+
1004
+ @ Test
1005
+ public void borderBoxSizingTest () throws IOException , InterruptedException {
1006
+ String filename = DESTINATION_FOLDER + "borderBoxSizingTest.pdf" ;
1007
+ String cmpName = SOURCE_FOLDER + "cmp_borderBoxSizingTest.pdf" ;
1008
+ java .util .List <TemplateValue > columnsTemplate = new ArrayList <>();
1009
+ columnsTemplate .add (new AutoRepeatValue (true , Arrays .asList ((GridValue ) new PointValue (200 ))));
1010
+
1011
+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
1012
+ GridContainer grid = new GridContainer ();
1013
+ grid .setWidth (420 );
1014
+ grid .setBorder (new SolidBorder (20 ));
1015
+ grid .setPadding (20 );
1016
+ grid .setMargin (20 );
1017
+ grid .setProperty (Property .GRID_TEMPLATE_COLUMNS , columnsTemplate );
1018
+ grid .setProperty (Property .COLUMN_GAP , 20.0f );
1019
+ grid .add (new Paragraph ("One" ).setBackgroundColor (ColorConstants .CYAN ));
1020
+
1021
+ final Paragraph two = new Paragraph ("Two" ).setBackgroundColor (ColorConstants .CYAN );
1022
+ two .setProperty (Property .BOX_SIZING , BoxSizingPropertyValue .BORDER_BOX );
1023
+ two .setPadding (10 );
1024
+ two .setMargin (10 );
1025
+ two .setBorder (new SolidBorder (ColorConstants .BLUE , 10 ));
1026
+
1027
+ grid .add (two );
1028
+ grid .add (new Paragraph ("Tree" ).setBackgroundColor (ColorConstants .CYAN ));
1029
+ grid .add (new Paragraph ("Four" ).setBackgroundColor (ColorConstants .CYAN ));
1030
+ grid .add (new Paragraph ("Five" ).setBackgroundColor (ColorConstants .CYAN ));
1031
+ grid .add (new Paragraph ("Six" ).setBackgroundColor (ColorConstants .CYAN ));
1032
+ grid .add (new Paragraph ("Seven" ).setBackgroundColor (ColorConstants .CYAN ));
1033
+ grid .add (new Paragraph ("Eight" ).setBackgroundColor (ColorConstants .CYAN ));
1034
+ grid .add (new Paragraph ("Nine" ).setBackgroundColor (ColorConstants .CYAN ));
1035
+
1036
+ document .add (grid );
1037
+ }
1038
+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
1039
+ }
1040
+
1041
+ @ Test
1042
+ public void marginCollapsingTest () throws IOException , InterruptedException {
1043
+ String filename = DESTINATION_FOLDER + "marginCollapsingTest.pdf" ;
1044
+ String cmpName = SOURCE_FOLDER + "cmp_marginCollapsingTest.pdf" ;
1045
+ java .util .List <TemplateValue > columnsTemplate = new ArrayList <>();
1046
+ columnsTemplate .add (new AutoRepeatValue (true , Arrays .asList ((GridValue ) new PointValue (200 ))));
1047
+
1048
+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
1049
+ GridContainer grid = new GridContainer ();
1050
+ grid .setWidth (420 );
1051
+ grid .setBorder (new SolidBorder (20 ));
1052
+ grid .setPadding (20 );
1053
+ grid .setMargin (20 );
1054
+ grid .setProperty (Property .GRID_TEMPLATE_COLUMNS , columnsTemplate );
1055
+ grid .setProperty (Property .COLUMN_GAP , 20.0f );
1056
+ grid .add (new Paragraph ("One" ).setBackgroundColor (ColorConstants .CYAN ));
1057
+
1058
+ Div twoParent = new Div ();
1059
+ final Paragraph two = new Paragraph ("Two" ).setBackgroundColor (ColorConstants .CYAN );
1060
+ twoParent .add (two );
1061
+ twoParent .add (new Div ());
1062
+ grid .add (twoParent );
1063
+ grid .add (new Paragraph ("Tree" ).setBackgroundColor (ColorConstants .CYAN ));
1064
+ grid .add (new Paragraph ("Four" ).setBackgroundColor (ColorConstants .CYAN ));
1065
+ grid .add (new Paragraph ("Five" ).setBackgroundColor (ColorConstants .CYAN ));
1066
+ grid .add (new Paragraph ("Six" ).setBackgroundColor (ColorConstants .CYAN ));
1067
+ grid .add (new Paragraph ("Seven" ).setBackgroundColor (ColorConstants .CYAN ));
1068
+ grid .add (new Paragraph ("Eight" ).setBackgroundColor (ColorConstants .CYAN ));
1069
+ grid .add (new Paragraph ("Nine" ).setBackgroundColor (ColorConstants .CYAN ));
1070
+
1071
+ document .add (grid );
1072
+ }
1073
+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
1074
+ }
972
1075
}
0 commit comments