Text rotation in FloatingBox produces odd output

Rotating the text in a FloatingBox produces strange output.
Rotation by 90 or 270 produces a single line
Rotating by 180 creates a mirror image with the lines of text in reverse order.

The PDF below was produced by creating a series of FloatingBoxes with different rotations.

Annotated Example.pdf (147.1 KB)

        AddTextBox(page, "Box Number One", new AnnotationDetails(180, 120, 60, 60), 0);
        AddTextBox(page, "Box Number Two",   new AnnotationDetails(220, 160, 60, 60), 90);
        AddTextBox(page, "Box Number Three", new AnnotationDetails(260, 200, 60, 60), 180);
        AddTextBox(page, "Box Number Four",  new AnnotationDetails(300, 240, 60, 60), 270);
        AddTextBox(page, "Box Number Five",  new AnnotationDetails(340, 280, 60, 60), 0);
private static void AddRotatedTextBox(Page page, string message, AnnotationDetails details)
{
    Console.WriteLine($"TextBox Top:{details.Top:000} Left:{details.Left:000} Width:{details.Width:000} Height:{details.Height:000} Background:{backgroundColorARGB:X} {message}");

    var padding = 1;

    details.Left = (float)page.Rect.Width - details.Left;
    details.Top = (float)page.Rect.Height - details.Top;

    var left = (double)details.Left + padding - page.PageInfo.Margin.Left;
    var top = (double)details.Top + padding - page.PageInfo.Margin.Top;

    var box = new FloatingBox((float)details.Width-padding, (float)details.Height-padding)
    {
        Border = new BorderInfo(BorderSide.All, borderColorARGB == 0 ? 0.0f : 1.0f, PdfColor.Green),
        IsNeedRepeating = false,

        Left = left,
        Top = top,

        IsInLineParagraph = false,
        IsInNewPage = false,
        HorizontalAlignment = HorizontalAlignment.Left,
        VerticalAlignment = VerticalAlignment.Top,

        Margin = new MarginInfo(0, 0, 0, 0),
        Padding = new MarginInfo(0, 0, 0, 0),

        PositioningMode = ParagraphPositioningMode.Absolute,

    };

    var text = new TextFragment($"{message}[Left:{left:000} Top:{top:000}");

    text.TextState.ForegroundColor = GetColorFromARGB((uint)fontColorARGB);
    text.TextState.Font = FontRepository.FindFont(fontName);
    text.TextState.FontSize = (float)fontSize;
    text.TextState.Rotation = 180;

    box.Paragraphs.Add(text);
    page.Paragraphs.Add(box);

    AddRectangle(page, (double)details.Left, (double)details.Top, (double)details.Width, (double)details.Height
        , (uint)backgroundColorARGB
        , (uint)borderColorARGB
        , (details.Zorder ?? 0) - 1,
        10);


}

@srmorley

It seems you’re experiencing issues with text rotation in FloatingBox elements in Aspose.PDF. Here are some suggestions to troubleshoot the problem:

  1. Check the Rotation Property: Ensure that you are setting the rotation property correctly for the FloatingBox. You can set the rotation using the Rotation property of the FloatingBox object.

  2. Verify the Transformation Matrix: If you are applying transformations, check if the transformation matrix is correctly set, as this can affect how text is rendered within the FloatingBox.

  3. Text Alignment and Positioning: Make sure that the text alignment and positioning within the FloatingBox are set correctly. The rotation may cause the text to appear off-center if the alignment is not adjusted.

  4. Use the Correct Page Orientation: If the FloatingBox is placed on a rotated page, ensure that the page orientation aligns with your expectations.

  5. Update Aspose.PDF Library: Ensure you are using the latest version of the Aspose.PDF library, as older versions may contain bugs that have been fixed in newer releases.

  6. Check for Overlapping Elements: If there are other elements in the PDF that might overlap with the FloatingBox, this could cause issues with how the text is displayed. Adjust the layout or z-order if needed.

  7. Debugging Output: Add debugging output to see the dimensions and properties of the FloatingBox before and after rotation. This can help identify if the values are what you expect.

If the issue persists, consider sharing a minimal code snippet that reproduces the problem, along with details about your environment and any error messages you might be receiving. This will help in diagnosing the issue more effectively.

I think your AI needs a tune up as I don’t see a Rotation property on the FloatingBox - it was the first place I looked for that but since there isn’t one I tried rotating the text itself.

@srmorley

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-60736

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.