Skip to content

Commit 4f25802

Browse files
committed
Add a test for chunks that end before or after the tab's position.
SUP-3710
1 parent c1233fd commit 4f25802

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ This file is part of the iText (R) project.
5959
import com.itextpdf.layout.element.Paragraph;
6060
import com.itextpdf.layout.element.Tab;
6161
import com.itextpdf.layout.element.TabStop;
62+
import com.itextpdf.layout.element.Text;
6263
import com.itextpdf.layout.property.Property;
6364
import com.itextpdf.layout.property.TabAlignment;
6465
import com.itextpdf.test.ExtendedITextTest;
@@ -107,6 +108,35 @@ public static void beforeClass() {
107108
createOrClearDestinationFolder(destinationFolder);
108109
}
109110

111+
@Test
112+
public void chunkEndsAfterOrBeforeTabPosition() throws IOException, InterruptedException {
113+
String outFileName = destinationFolder + "chunkEndsAfterOrBeforeTabPosition.pdf";
114+
String cmpFileName = sourceFolder + "cmp_chunkEndsAfterOrBeforeTabPosition.pdf";
115+
116+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
117+
Document doc = new Document(pdfDoc);
118+
119+
String textBeforeTab = "a";
120+
String textAfterTab = "tab stop's position = ";
121+
122+
Paragraph paragraph;
123+
for (int i = 0; i < 20; i++) {
124+
paragraph = new Paragraph();
125+
paragraph.add(new Text(textBeforeTab));
126+
TabStop[] tabStop = new TabStop[1];
127+
tabStop[0] = new TabStop(i);
128+
paragraph.addTabStops(tabStop);
129+
paragraph.add(new Tab());
130+
paragraph.add(new Text(textAfterTab));
131+
paragraph.add(Integer.toString(i));
132+
doc.add(paragraph);
133+
}
134+
135+
doc.close();
136+
137+
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"));
138+
}
139+
110140
@Test
111141
public void defaultTabsTest() throws IOException, InterruptedException {
112142
String outFileName = destinationFolder + "defaultTabTest.pdf";
@@ -478,6 +508,7 @@ public void tabsAnchorSemicolonTest03() throws IOException, InterruptedException
478508
private Document initDocument(String outFileName) throws FileNotFoundException {
479509
return initDocument(outFileName, false);
480510
}
511+
481512
private Document initDocument(String outFileName, boolean tagged) throws FileNotFoundException {
482513
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
483514
if (tagged) {

0 commit comments

Comments
 (0)