@@ -87,6 +87,53 @@ public void basicThreeColumnsTest() throws IOException, InterruptedException {
8787 Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
8888 }
8989
90+ @ Test
91+ public void basicTwoColumnsTest () throws IOException , InterruptedException {
92+ String filename = DESTINATION_FOLDER + "basicTwoColumnsTest.pdf" ;
93+ String cmpName = SOURCE_FOLDER + "cmp_basicTwoColumnsTest.pdf" ;
94+
95+ java .util .List <TemplateValue > templateColumns = new ArrayList <>();
96+ templateColumns .add (new PointValue (150.0f ));
97+ templateColumns .add (new PointValue (150.0f ));
98+ SolidBorder border = new SolidBorder (ColorConstants .BLUE , 1 );
99+
100+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
101+ GridContainer grid = new GridContainer ();
102+ grid .setProperty (Property .GRID_TEMPLATE_COLUMNS , templateColumns );
103+ grid .add (new Paragraph ("One" ).setBorder (border ));
104+ grid .add (new Paragraph ("Two" ).setBorder (border ));
105+ Paragraph paragraph3 = new Paragraph ("One" ).setBorder (border );
106+ paragraph3 .setProperty (Property .GRID_COLUMN_SPAN , 2 );
107+ grid .add (paragraph3 );
108+ document .add (grid );
109+ }
110+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
111+ }
112+
113+ @ Test
114+ public void basicTwoRowsTest () throws IOException , InterruptedException {
115+ String filename = DESTINATION_FOLDER + "basicTwoRowsTest.pdf" ;
116+ String cmpName = SOURCE_FOLDER + "cmp_basicTwoRowsTest.pdf" ;
117+
118+ java .util .List <TemplateValue > templateRows = new ArrayList <>();
119+ templateRows .add (new PointValue (150.0f ));
120+ templateRows .add (new PointValue (150.0f ));
121+ SolidBorder border = new SolidBorder (ColorConstants .BLUE , 1 );
122+
123+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
124+ GridContainer grid = new GridContainer ();
125+ grid .setProperty (Property .GRID_TEMPLATE_ROWS , templateRows );
126+ grid .setProperty (Property .GRID_FLOW , GridFlow .COLUMN );
127+ grid .add (new Paragraph ("One" ).setBorder (border ));
128+ grid .add (new Paragraph ("Two" ).setBorder (border ));
129+ Paragraph paragraph3 = new Paragraph ("One" ).setBorder (border );
130+ paragraph3 .setProperty (Property .GRID_ROW_SPAN , 2 );
131+ grid .add (paragraph3 );
132+ document .add (grid );
133+ }
134+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
135+ }
136+
90137 @ Test
91138 public void basicAutoColumnsTest () throws IOException , InterruptedException {
92139 String filename = DESTINATION_FOLDER + "basicAutoColumnsTest.pdf" ;
@@ -154,6 +201,68 @@ public void basicThreeColumnsWithCustomColumnIndexesTest() throws IOException, I
154201 Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
155202 }
156203
204+ @ Test
205+ public void basicThreeColumnsOutOfBoundsWithNoCellsTest () throws IOException , InterruptedException {
206+ String filename = DESTINATION_FOLDER + "basicThreeColumnsOutOfBoundsWithNoCellsTest.pdf" ;
207+ String cmpName = SOURCE_FOLDER + "cmp_basicThreeColumnsOutOfBoundsWithNoCellsTest.pdf" ;
208+
209+ java .util .List <TemplateValue > templateColumns = new ArrayList <>();
210+ templateColumns .add (new PointValue (100.0f ));
211+ templateColumns .add (new PointValue (100.0f ));
212+ templateColumns .add (new PointValue (100.0f ));
213+ SolidBorder border = new SolidBorder (ColorConstants .BLUE , 1 );
214+
215+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
216+ GridContainer grid = new GridContainer ();
217+ grid .setProperty (Property .GRID_TEMPLATE_COLUMNS , templateColumns );
218+ Paragraph paragraph1 = new Paragraph ("One" ).setBorder (border );
219+ paragraph1 .setProperty (Property .GRID_COLUMN_START , -2 );
220+ paragraph1 .setProperty (Property .GRID_COLUMN_END , -1 );
221+ grid .add (paragraph1 );
222+ grid .add (new Paragraph ("Two" ).setBorder (border ));
223+ Paragraph paragraph3 = new Paragraph ("Three" ).setBorder (border );
224+ paragraph3 .setProperty (Property .GRID_COLUMN_START , -4 );
225+ paragraph3 .setProperty (Property .GRID_COLUMN_END , 3 );
226+ grid .add (paragraph3 );
227+ grid .add (new Paragraph ("Four" ).setBorder (border ));
228+ document .add (grid );
229+ }
230+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
231+ }
232+
233+ @ Test
234+ public void basicThreeColumnsWithNegativeCustomColumnIndexesTest () throws IOException , InterruptedException {
235+ String filename = DESTINATION_FOLDER + "basicThreeColumnsWithNegativeCustomColumnIndexesTest.pdf" ;
236+ String cmpName = SOURCE_FOLDER + "cmp_basicThreeColumnsWithNegativeCustomColumnIndexesTest.pdf" ;
237+
238+ java .util .List <TemplateValue > templateColumns = new ArrayList <>();
239+ templateColumns .add (new PointValue (100.0f ));
240+ templateColumns .add (new PointValue (100.0f ));
241+ templateColumns .add (new PointValue (100.0f ));
242+ SolidBorder border = new SolidBorder (ColorConstants .BLUE , 1 );
243+
244+ try (Document document = new Document (new PdfDocument (new PdfWriter (filename )))) {
245+ GridContainer grid = new GridContainer ();
246+ grid .setProperty (Property .GRID_TEMPLATE_COLUMNS , templateColumns );
247+ Paragraph paragraph1 = new Paragraph ("One" ).setBorder (border );
248+ paragraph1 .setProperty (Property .GRID_COLUMN_START , -2 );
249+ paragraph1 .setProperty (Property .GRID_COLUMN_END , -1 );
250+ grid .add (paragraph1 );
251+ grid .add (new Paragraph ("Two" ).setBorder (border ));
252+ Paragraph paragraph3 = new Paragraph ("Three" ).setBorder (border );
253+ paragraph3 .setProperty (Property .GRID_COLUMN_START , -7 );
254+ paragraph3 .setProperty (Property .GRID_COLUMN_END , 3 );
255+ grid .add (paragraph3 );
256+ grid .add (new Paragraph ("Four" ).setBorder (border ));
257+ grid .add (new Paragraph ("Five" ).setBorder (border ));
258+ grid .add (new Paragraph ("Six" ).setBorder (border ));
259+ grid .add (new Paragraph ("Seven" ).setBorder (border ));
260+ grid .add (new Paragraph ("Eight" ).setBorder (border ));
261+ document .add (grid );
262+ }
263+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpName , DESTINATION_FOLDER , "diff_" ));
264+ }
265+
157266 @ Test
158267 public void threeColumnsWithAdjacentWideCellsTest () throws IOException , InterruptedException {
159268 String filename = DESTINATION_FOLDER + "threeColumnsWithAdjacentWideCellsTest.pdf" ;
0 commit comments