Skip to content

Commit 7669c36

Browse files
ars18wrwiText-CI
authored andcommitted
Consider correct borders while skipping the last footer.
DEVSIX-2228
1 parent c3d3aea commit 7669c36

File tree

5 files changed

+59
-8
lines changed

5 files changed

+59
-8
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/TableRenderer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ public LayoutResult layout(LayoutContext layoutContext) {
601601
if (null != headerRenderer) {
602602
overflowRenderer.setProperty(Property.BORDER_TOP, Border.NO_BORDER);
603603
}
604-
overflowRenderer.rowRange = new Table.RowRange(0, rows.size() - row - 1);
605604
overflowRenderer.bordersHandler = bordersHandler;
606605
// save old bordersHandler properties
607606
bordersHandler.skipFooter(overflowRenderer.getBorders());

layout/src/test/java/com/itextpdf/layout/TableTest.java

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,20 +2512,46 @@ public void spacingTest01() throws IOException, InterruptedException {
25122512
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff"));
25132513
}
25142514

2515-
//exception to be fixed in DEVSIX-2228
25162515
@Test
2517-
public void rowspanTest() throws IOException{
2518-
//actually ArrayIndexOutOfBoundsException is expected, but it won't be ported.
2519-
junitExpectedException.expect(RuntimeException.class);
2520-
String outFileName = destinationFolder + "rowspanTest.pdf";
2516+
public void skipLastFooterAndProcessBigRowspanTest01() throws IOException, InterruptedException {
2517+
String testName = "skipLastFooterAndProcessBigRowspanTest01.pdf";
2518+
String outFileName = destinationFolder + testName;
2519+
String cmpFileName = sourceFolder + "cmp_" + testName;
2520+
2521+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
2522+
Document doc = new Document(pdfDoc, new PageSize(595, 140));
2523+
Table table = new Table(2);
2524+
2525+
table.setSkipLastFooter(true);
2526+
2527+
table.addFooterCell(new Cell(1, 2).add(new Paragraph("Footer")));
2528+
table.addCell(new Cell(3, 1).add(new Paragraph(Integer.toString(1))));
2529+
for (int z = 0; z < 3; z++) {
2530+
table.addCell(new Cell().add(new Paragraph(Integer.toString(z))));
2531+
}
2532+
2533+
doc.add(table);
2534+
doc.close();
2535+
2536+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff"));
2537+
}
2538+
2539+
@Test
2540+
public void skipLastFooterAndProcessBigRowspanTest02() throws IOException, InterruptedException {
2541+
String testName = "skipLastFooterAndProcessBigRowspanTest02.pdf";
2542+
String outFileName = destinationFolder + testName;
2543+
String cmpFileName = sourceFolder + "cmp_" + testName;
2544+
25212545
int numRows = 3;
2522-
PdfWriter writer = new PdfWriter(outFileName);
2523-
PdfDocument pdfDoc = new PdfDocument(writer);
2546+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
25242547
Document doc = new Document(pdfDoc);
2548+
25252549
Table table = new Table(numRows);
25262550
table.setSkipLastFooter(true);
2551+
25272552
table.addHeaderCell(new Cell(1, numRows).add(new Paragraph("Header")));
25282553
table.addFooterCell(new Cell(1, numRows).add(new Paragraph("Footer")));
2554+
25292555
for (int rows = 0; rows < 11; rows++) {
25302556
table.addCell(new Cell(numRows, 1).add(new Paragraph("Filled Cell: " + Integer.toString(rows) + ", 0")));
25312557
int numFillerCells = (numRows -1) * numRows; //Number of cells to complete the table rows filling up to the cell of colSpan
@@ -2535,6 +2561,32 @@ public void rowspanTest() throws IOException{
25352561
}
25362562
doc.add(table);
25372563
doc.close();
2564+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff"));
2565+
}
2566+
2567+
@Test
2568+
public void skipLastFooterOnShortPageTest01() throws IOException, InterruptedException {
2569+
String testName = "skipLastFooterOnShortPageTest01.pdf";
2570+
String outFileName = destinationFolder + testName;
2571+
String cmpFileName = sourceFolder + "cmp_" + testName;
2572+
2573+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
2574+
Document doc = new Document(pdfDoc, new PageSize(595, 120));
2575+
Table table = new Table(2);
2576+
2577+
table.setSkipLastFooter(true);
2578+
2579+
table.addFooterCell(new Cell(1, 2).add(new Paragraph("Footer")));
2580+
for (int z = 0; z < 2; z++) {
2581+
for (int i = 0; i < 2; i++) {
2582+
table.addCell(new Cell().add(new Paragraph(Integer.toString(z))));
2583+
}
2584+
}
2585+
2586+
doc.add(table);
2587+
doc.close();
2588+
2589+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff"));
25382590
}
25392591

25402592
static class CustomRenderer extends TableRenderer {

0 commit comments

Comments
 (0)