Skip to content

Commit cbf02be

Browse files
committed
Add new large table test.
DEVSIX-1603
1 parent c2d7e35 commit cbf02be

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,45 @@ public void largeTableWithLayoutResultNothingTest03() throws IOException, Interr
501501
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff"));
502502
}
503503

504+
@Test
505+
public void largeTableOnDifferentPages01() throws IOException, InterruptedException {
506+
String testName = "largeTableOnDifferentPages01.pdf";
507+
String outFileName = destinationFolder + testName;
508+
String cmpFileName = sourceFolder + "cmp_" + testName;
509+
510+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
511+
Document doc = new Document(pdfDoc, PageSize.A4.rotate());
512+
513+
float[] colWidths = new float[]{200, -1, 20, 40};
514+
515+
Table table = new Table(UnitValue.createPointArray(colWidths), true);
516+
doc.add(table);
517+
518+
// change the second page's size
519+
pdfDoc.setDefaultPageSize(PageSize.A3.rotate());
520+
521+
for (int i = 0; i < 25; i++) {
522+
table.addCell(new Cell().add("Cell" + (i*4 + 0)));
523+
table.addCell(new Cell().add("Cell" + (i*4 + 1)));
524+
table.addCell(new Cell().add("Cell" + (i*4 + 2)));
525+
table.addCell(new Cell().add("Cell" + (i*4 + 3)));
526+
527+
table.flush();
528+
529+
// change the third page's size
530+
if (i == 20) {
531+
pdfDoc.setDefaultPageSize(PageSize.A5.rotate());
532+
533+
}
534+
}
535+
536+
table.complete();
537+
538+
doc.close();
539+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff"));
540+
}
541+
542+
504543
@Test
505544
public void largeEmptyTableTest() throws IOException, InterruptedException {
506545
String testName = "largeEmptyTableTest.pdf";

0 commit comments

Comments
 (0)