Rotate Text in PDF using Java | Aspose.PDF | word wrapping does not work correctly for rotated text

We have noticed that when TextFragments are rotated, line wrapping does not work correctly. Code example below.

@Test
public void test_text_rotation() throws Exception {
    final Document document = new Document();

    final String text = "fizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzzfizzbuzz";
    final TextFragment textFragment = new TextFragment(text);

    textFragment.setPosition(new Position(100, 100));
    textFragment.getTextState().setRotation(90.0);

    final Page page = document.getPages().add();
    page.getParagraphs().add(textFragment);

    document.save("../test.pdf");
}

@zhaolang

We were able to replicate the issue in our environment when we tested the scenario using Aspose.PDF for Java 21.3. Therefore, a ticket as PDFJAVA-40297 has been logged in our issue tracking system for the issue. We will further look into its details and keep you informed about its rectification status. Please be patient and spare us some time.

We are sorry for the inconvenience.