@@ -22,14 +22,13 @@ This file is part of the iText (R) project.
2222 */
2323package com .itextpdf .layout .element ;
2424
25- import com .itextpdf .io .logs .IoLogMessageConstant ;
2625import com .itextpdf .kernel .colors .ColorConstants ;
2726import com .itextpdf .kernel .pdf .PdfDocument ;
2827import com .itextpdf .kernel .pdf .PdfWriter ;
2928import com .itextpdf .kernel .utils .CompareTool ;
3029import com .itextpdf .layout .Document ;
3130import com .itextpdf .layout .borders .SolidBorder ;
32- import com .itextpdf .layout .exceptions . LayoutExceptionMessageConstant ;
31+ import com .itextpdf .layout .properties . BoxSizingPropertyValue ;
3332import com .itextpdf .layout .properties .Property ;
3433import com .itextpdf .layout .properties .UnitValue ;
3534import com .itextpdf .layout .properties .grid .AutoRepeatValue ;
@@ -45,8 +44,6 @@ This file is part of the iText (R) project.
4544import com .itextpdf .layout .properties .grid .PointValue ;
4645import com .itextpdf .layout .properties .grid .TemplateValue ;
4746import com .itextpdf .test .ExtendedITextTest ;
48- import com .itextpdf .test .annotations .LogMessage ;
49- import com .itextpdf .test .annotations .LogMessages ;
5047import com .itextpdf .test .annotations .type .IntegrationTest ;
5148
5249import java .io .IOException ;
@@ -969,4 +966,110 @@ public void marginsCollapsingIssueTest() throws IOException, InterruptedExceptio
969966 }
970967 Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
971968 }
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+ }
9721075}
0 commit comments