我可以看到,当文本左对齐时,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"));
}