【问题标题】:itext 7 rotated text in the table's cellitext 7 旋转表格单元格中的文本
【发布时间】:2016-08-01 18:34:27
【问题描述】:

在表格中以指定宽度和旋转文本呈现单元格时似乎存在错误。如果旋转角度为 (Math.PI / 2),则文本渗入相邻单元格,如果旋转角度为 -(Math.PI / 2),则单元格高度延伸到页面底部。

这是单元测试:

@Test
public void tableRotationTest02() throws IOException,InterruptedException {
    String outFileName = OUTPUT_FOLDER + "tableRotationTest02.pdf";
//        String cmpFileName = sourceFolder + cmpPrefix + "tableRotationTest02.pdf";

//        FileOutputStream file = new FileOutputStream(outFileName);
    PdfWriter writer = new PdfWriter(outFileName);
    PdfDocument pdfDoc = new PdfDocument(writer);
    Document doc = new Document(pdfDoc);

    Table table = new Table(new float[]{25, 50})
            .addCell(new Cell().add(new Paragraph("cell 1, 1").setRotationAngle((Math.PI / 2))))
            .addCell(new Cell().add(new Paragraph("cell 1, 2").setRotationAngle((Math.PI / 3))))
            .addCell(new Cell().add(new Paragraph("cell 2, 1").setRotationAngle(-(Math.PI / 2))))
            .addCell(new Cell().add(new Paragraph("cell 2, 2").setRotationAngle((Math.PI))));
    doc.add(table);

    doc.close();

//        Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"));
}

【问题讨论】:

  • 感谢您提供独立的代码示例。这确实是一个错误。我们将看看它。

标签: itext7


【解决方案1】:

这确实是一个错误,已在 iText 中修复。
https://github.com/itext/itext7/blob/develop/layout/src/test/java/com/itextpdf/layout/RotationTest.java

感谢您报告此事。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 2017-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 2019-07-30
    相关资源
    最近更新 更多