我可以看到,当文本左对齐时,iText7 将正确呈现选项卡,但对于右对齐文本,选项卡认为文本左对齐并呈现为文本左对齐。
有谁知道这是我遗漏的东西引起的问题,还是iText7中的限制/错误?
更新:
@Test
public void shouldTabFromTheRightWhenTextAlignIsFromTheRight() throws IOException, InterruptedException {
String outFileName = destinationFolder + "tabRightAlignedTextTest.pdf";
String cmpFileName = sourceFolder + "cmp_tabRightAlignedTextTest.pdf";
FileOutputStream file = new FileOutputStream(outFileName);
PdfWriter writer = new PdfWriter(file);
PdfDocument pdfDoc = new PdfDocument(writer);
Document doc = new Document(pdfDoc);
Paragraph p = new Paragraph();
p.setFontColor(Color.GREEN);
p.setTextAlignment(TextAlignment.RIGHT);
p.add(new Text("text out of page"));
p.add(new Tab());
p.add(new Text(" bounds after right tab stop:"));
doc.add(p);
p = new Paragraph();
p.setFontColor(Color.GREEN);
p.setTextAlignment(TextAlignment.RIGHT);
p.add(new Text("text out of"));
p.add(new Tab());
p.add(new Text(" page bounds after right tab stop:"));
doc.add(p);
p = new Paragraph();
p.setFontColor(Color.GREEN);
p.add(new Text("text out of page"));
p.add(new Tab());
p.add(new Text(" bounds after right tab stop:"));
doc.add(p);
p = new Paragraph();
p.setFontColor(Color.GREEN);
p.add(new Text("text out of"));
p.add(new Tab());
p.add(new Text(" page bounds after right tab stop:"));
doc.add(p);
doc.close();
Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"));
}