@@ -1206,6 +1206,37 @@ public void splitTableOnShortPage() throws IOException, InterruptedException {
1206
1206
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , testName + "_diff" ));
1207
1207
}
1208
1208
1209
+ @ Test
1210
+ public void splitCellWithStyles () throws IOException , InterruptedException {
1211
+ String testName = "splitCellWithStyles.pdf" ;
1212
+ String outFileName = destinationFolder + testName ;
1213
+ String cmpFileName = sourceFolder + "cmp_" + testName ;
1214
+
1215
+ String text = "Make Gretzky Great Again" ;
1216
+
1217
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
1218
+ Document doc = new Document (pdfDoc , PageSize .A7 );
1219
+
1220
+ Table table = new Table (2 )
1221
+ .setBorder (Border .NO_BORDER )
1222
+ .setMarginTop (10 )
1223
+ .setMarginBottom (10 );
1224
+ Style cellStyle = new Style ();
1225
+ cellStyle .setBorderLeft (Border .NO_BORDER )
1226
+ .setBorderRight (Border .NO_BORDER )
1227
+ .setBorderTop (new SolidBorder (Color .BLUE , 1 ))
1228
+ .setBorderBottom (new SolidBorder (Color .BLUE , 1 ));
1229
+ for (int i = 0 ; i < 10 ; i ++) {
1230
+ table .addCell (new Cell ().add (Integer .toString (i )).addStyle (cellStyle ));
1231
+ table .addCell (new Cell ().add (text ).addStyle (cellStyle ));
1232
+ }
1233
+
1234
+ doc .add (table );
1235
+
1236
+ doc .close ();
1237
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , testName + "_diff" ));
1238
+ }
1239
+
1209
1240
@ Test
1210
1241
public void imageInTableTest_HA () throws IOException , InterruptedException {
1211
1242
String testName = "imageInTableTest_HA.pdf" ;
@@ -1253,6 +1284,28 @@ public void cellAlignmentAndSplittingTest01() throws IOException, InterruptedExc
1253
1284
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , testName + "_diff" ));
1254
1285
}
1255
1286
1287
+
1288
+ @ Test
1289
+ public void memoryTest01 () throws IOException , InterruptedException {
1290
+ String testName = "memoryTest01.pdf" ;
1291
+ String outFileName = destinationFolder + testName ;
1292
+ String cmpFileName = sourceFolder + "cmp_" + testName ;
1293
+
1294
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
1295
+ Document doc = new Document (pdfDoc );
1296
+
1297
+ Table table = new Table (5 );
1298
+ for (int i = 0 ; i < 20000 ; i ++) {
1299
+ for (int j = 0 ; j < 5 ; j ++) {
1300
+ table .addCell (j + " Liberté!\n Égalité!\n Fraternité!" );
1301
+ }
1302
+ }
1303
+ doc .add (table );
1304
+
1305
+ doc .close ();
1306
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , testName + "_diff" ));
1307
+ }
1308
+
1256
1309
@ Test
1257
1310
public void cellAlignmentAndKeepTogetherTest01 () throws IOException , InterruptedException {
1258
1311
String testName = "cellAlignmentAndKeepTogetherTest01.pdf" ;
@@ -1549,7 +1602,7 @@ public void tableWithHeaderInTheBottomOfPageTest() throws IOException, Interrupt
1549
1602
doc .add (new Paragraph ("Text" ));
1550
1603
}
1551
1604
1552
- Table table = new Table (UnitValue .createPercentArray (new float [] {10 , 10 }));
1605
+ Table table = new Table (UnitValue .createPercentArray (new float []{10 , 10 }));
1553
1606
table .addHeaderCell (new Cell ().add ("Header One" ));
1554
1607
table .addHeaderCell (new Cell ().add ("Header Two" ));
1555
1608
table .addCell (new Cell ().add ("Hello" ));
@@ -1613,7 +1666,7 @@ public void tableWithDocumentRelayoutTest() throws IOException, InterruptedExcep
1613
1666
PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
1614
1667
Document doc = new Document (pdfDoc , PageSize .A4 , false );
1615
1668
1616
- Table table = new Table (UnitValue .createPercentArray (new float [] {10 }));
1669
+ Table table = new Table (UnitValue .createPercentArray (new float []{10 }));
1617
1670
for (int i = 0 ; i < 40 ; i ++) {
1618
1671
table .addCell (new Cell ().add ("" + (i + 1 )));
1619
1672
}
@@ -1633,7 +1686,7 @@ public void tableWithKeepTogetherOnCells() throws IOException, InterruptedExcept
1633
1686
1634
1687
Document document = new Document (new PdfDocument (new PdfWriter (outFileName )));
1635
1688
1636
- Table table = new Table (UnitValue .createPercentArray (new float [] { 1.3f , 1f , 1f , 1f , 1f , 1f , 1f }));
1689
+ Table table = new Table (UnitValue .createPercentArray (new float []{ 1.3f , 1f , 1f , 1f , 1f , 1f , 1f }));
1637
1690
table .setWidthPercent (100f ).setFixedLayout ();
1638
1691
for (int i = 1 ; i <= 7 * 100 ; i ++) {
1639
1692
Cell cell = new Cell ().setKeepTogether (true ).setMinHeight (45 ).add ("" + i );
@@ -1899,7 +1952,7 @@ public void tableNothingResultTest() throws IOException, InterruptedException {
1899
1952
PdfDocument pdfDoc = new PdfDocument (new PdfWriter (outFileName ));
1900
1953
Document doc = new Document (pdfDoc );
1901
1954
1902
- Table table = new Table (UnitValue .createPercentArray (new float [] {30 , 30 }));
1955
+ Table table = new Table (UnitValue .createPercentArray (new float []{30 , 30 }));
1903
1956
table .setKeepTogether (true );
1904
1957
for (int i = 0 ; i < 40 ; i ++) {
1905
1958
table .addCell (new Cell ().add ("Hello" ));
@@ -1979,7 +2032,7 @@ public void fixedLayoutTest01() throws IOException, InterruptedException {
1979
2032
Document doc = new Document (pdf );
1980
2033
1981
2034
doc .add (new Paragraph ("Simple table with proportional width. Ignore cell width, because sum(col[*]) < tableWidth:" ));
1982
- Table table = new Table (new float [] {1 ,2 , 3 }).setFixedLayout ().setWidth (400 );
2035
+ Table table = new Table (new float []{1 , 2 , 3 }).setFixedLayout ().setWidth (400 );
1983
2036
table .addCell ("1x" );
1984
2037
table .addCell ("2x" );
1985
2038
table .addCell ("3x" );
@@ -2001,7 +2054,7 @@ public void fixedLayoutTest02() throws IOException, InterruptedException {
2001
2054
Document doc = new Document (pdf );
2002
2055
2003
2056
doc .add (new Paragraph ("Simple table with proportional width. Ignore table width, because sum(col[*]) > tableWidth." ));
2004
- Table table = new Table (new float [] {20 ,40 ,60 }).setFixedLayout ().setWidth (10 );
2057
+ Table table = new Table (new float []{20 , 40 , 60 }).setFixedLayout ().setWidth (10 );
2005
2058
table .addCell ("1x" );
2006
2059
table .addCell ("2x" );
2007
2060
table .addCell ("3x" );
0 commit comments