@@ -46,6 +46,7 @@ This file is part of the iText (R) project.
4646import com .itextpdf .kernel .colors .ColorConstants ;
4747import com .itextpdf .kernel .font .PdfFont ;
4848import com .itextpdf .kernel .font .PdfFontFactory ;
49+ import com .itextpdf .kernel .geom .PageSize ;
4950import com .itextpdf .kernel .pdf .PdfDocument ;
5051import com .itextpdf .kernel .pdf .PdfWriter ;
5152import com .itextpdf .kernel .pdf .canvas .PdfCanvasConstants ;
@@ -59,6 +60,7 @@ This file is part of the iText (R) project.
5960import com .itextpdf .layout .properties .Property ;
6061import com .itextpdf .test .ExtendedITextTest ;
6162import com .itextpdf .test .annotations .type .IntegrationTest ;
63+
6264import org .junit .Assert ;
6365import org .junit .BeforeClass ;
6466import org .junit .Test ;
@@ -403,4 +405,41 @@ public void leadingAndFloatInTextTest() throws IOException, InterruptedException
403405
404406 Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
405407 }
408+
409+ @ Test
410+ public void textWrappingEpsilonTest () throws IOException , InterruptedException {
411+ String outFileName = destinationFolder + "textWrappingEpsilon.pdf" ;
412+ String cmpFileName = sourceFolder + "cmp_textWrappingEpsilon.pdf" ;
413+
414+ PdfWriter writer = new PdfWriter (outFileName );
415+ PdfDocument pdfDoc = new PdfDocument (writer );
416+ Document document = new Document (pdfDoc );
417+
418+ // Play with margins to make AbstractRenderer.EPS important for wrapping behavior
419+ document .setLeftMargin (250.0F );
420+ document .setRightMargin (238.727F );
421+ pdfDoc .setDefaultPageSize (PageSize .LETTER );
422+ PdfFont font = PdfFontFactory .createFont (sourceFolder + "../fonts/Open_Sans/OpenSans-Regular.ttf" );
423+
424+ String text1 = "First line of some text " ;
425+ String text2 = "Second line of some text" ;
426+
427+ Text text = new Text (text1 );
428+ text .setFont (font );
429+ text .setFontSize (9 );
430+ Paragraph paragraph = new Paragraph ();
431+ paragraph .add (text );
432+
433+ text = new Text (text2 );
434+ text .setFont (font );
435+ text .setFontSize (9 );
436+ paragraph .add (text );
437+
438+ paragraph .setBackgroundColor (ColorConstants .LIGHT_GRAY );
439+ document .add (paragraph );
440+ document .close ();
441+ writer .close ();
442+
443+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
444+ }
406445}
0 commit comments