Text is cut off vertically on the page with 180 rotation

Hi all,

I was wondering if someone could help me and advise why the text of the text fragment object is cut off vertically on 180 rotation page.

Would be grateful for any help!

image.png (1.6 KB)

Sample:

    // Create Document instance
    Document doc = new Document();

    // Add page to pages collection of PDF file
    Aspose.Pdf.Page page = doc.Pages.Add();

    page.Rotate = Aspose.Pdf.Rotation::on180;

    Aspose.Pdf.Rectangle pageRect = page.GetPageRect(true);

    Aspose.Pdf.Text.TextParagraph paragraph = new Aspose.Pdf.Text.TextParagraph();

    paragraph.Rectangle                        = new Aspose.Pdf.Rectangle(110, pageRect.Height - 04, 190, pageRect.Height - 30);
    paragraph.VerticalAlignment                = Aspose.Pdf.VerticalAlignment::Top;
    paragraph.HorizontalAlignment              = Aspose.Pdf.HorizontalAlignment::Left;

    Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment('My text');

    textFragment.get_TextState().Font      = Aspose.Pdf.Text.FontRepository::FindFont("Calibri");
    textFragment.get_TextState().FontSize  = 10;
    textFragment.get_TextState().FontStyle = Aspose.Pdf.Text.FontStyles::Bold;
    
    // textFragment.get_TextState().BackgroundColor = Aspose.Pdf.Color::FromRgb(System.Drawing.Color::LightGray);

    paragraph.AppendLine(textFragment);
    
    Aspose.Pdf.Text.TextBuilder builder = new Aspose.Pdf.Text.TextBuilder(page);
    builder.AppendParagraph(paragraph);

    str dataDir = "C:\MyFile.pdf";

    // Save PDF file
    doc.Save(dataDir);

@cardagant

It looks like the API is not honoring Page Rotation correctly and text is being cut off. As a workaround, you can please set page rotation once document is saved. Please re-initialize the Document object with saved document and set the page rotation.

doc = new Document(dataDir + "TextCutOff.pdf");
doc.Pages[1].Rotate = Rotation.on180;
doc.Save(dataDir + "TextCutOff2.pdf");

OR if you want to rotate only text, you can set TextFragment.TextState.Rotation Property:

textFragment.TextState.Rotation = 180;

Furthermore, we have logged an issue as PDFNET-46505 in our issue tracking system. We will further investigate the reasons behind this issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hello! Thanks for the response!