@@ -57,6 +57,7 @@ This file is part of the iText (R) project.
57
57
import com .itextpdf .layout .properties .VerticalAlignment ;
58
58
import com .itextpdf .layout .renderer .DocumentRenderer ;
59
59
import com .itextpdf .layout .renderer .TableRenderer ;
60
+ import com .itextpdf .test .LogLevelConstants ;
60
61
import com .itextpdf .test .annotations .LogMessage ;
61
62
import com .itextpdf .test .annotations .LogMessages ;
62
63
import com .itextpdf .test .annotations .type .IntegrationTest ;
@@ -3521,6 +3522,41 @@ public void tableRelayoutTest() {
3521
3522
}
3522
3523
}
3523
3524
3525
+ @ Test
3526
+ @ LogMessages (messages = {
3527
+ @ LogMessage (messageTemplate = LayoutLogMessageConstant .ELEMENT_DOES_NOT_FIT_AREA , logLevel = LogLevelConstants .WARN )
3528
+ })
3529
+ public void infiniteLoopKeepTogetherTest () throws IOException , InterruptedException {
3530
+ String fileName = "infiniteLoopKeepTogether.pdf" ;
3531
+ float fontSize = 8 ;
3532
+
3533
+ try (PdfDocument pdfDoc = new PdfDocument (new PdfWriter (destinationFolder + fileName ));
3534
+ Document doc = new Document (pdfDoc )) {
3535
+ doc .setMargins (138 , 20 , 75 , 20 );
3536
+
3537
+ Table table = new Table (5 );
3538
+ table .setKeepTogether (true );
3539
+
3540
+ for (int i = 0 ; i < 37 ; i ++) {
3541
+ table .addCell (new Cell (1 , 5 ).add (new Paragraph (new Text ("Cell" ))).setFontSize (fontSize ));
3542
+ table .startNewRow ();
3543
+ }
3544
+
3545
+ Table commentsTable = new Table (1 );
3546
+ Cell commentsCell = new Cell ().add (new Paragraph (new Text ("First line\n Second line" )));
3547
+ commentsTable .addCell (commentsCell );
3548
+
3549
+ Cell outerCommentsCell = new Cell (1 , 5 ).setFontSize (fontSize );
3550
+ outerCommentsCell .add (commentsTable );
3551
+ table .addCell (outerCommentsCell );
3552
+
3553
+ doc .add (table );
3554
+ }
3555
+
3556
+ Assert .assertNull (new CompareTool ().compareByContent (destinationFolder + fileName ,
3557
+ sourceFolder + "cmp_" + fileName , destinationFolder ));
3558
+ }
3559
+
3524
3560
private static class RotatedDocumentRenderer extends DocumentRenderer {
3525
3561
private final PdfDocument pdfDoc ;
3526
3562
0 commit comments