wes.m
wes.m

Reputation: 53

itext 7 rotated text in the table's cell

There appears to be a bug rendering the cell in the table with specified width and rotated text. If the rotational angle is (Math.PI / 2) then the text bleeds into the neighboring cell and if the rotational angle is -(Math.PI / 2) then the cell height extends to the bottom of the page.

Here is the unit test:

@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"));
}

Upvotes: 2

Views: 1750

Answers (1)

Michaël Demey
Michaël Demey

Reputation: 1577

This was indeed a bug and this has been fixed in iText.
https://github.com/itext/itext7/blob/develop/layout/src/test/java/com/itextpdf/layout/RotationTest.java

Thanks for reporting this.

Upvotes: 1

Related Questions