Floating box issue - TextFragment not using full size of box

Hi there,

Added a floating box to my document which is A4 size. The margins and padding are all set to 0 as i want to use the full size of the pdf.

I have added a floating box that is the width of the page however the textfragment that have been added to the box randomly stop at the right hand side of it. Would someone help explain why this might be and even be able to advise me on how I can ensure my text uses all of the box.

Here is my code:

private DocumentInfoModel ComposeTodaysBusinessSection(DateOnly date)
{
try
{
// Instantiate PDF instance by calling empty constructor
License pdfLicense = new License();

    // Specify the license file path
    pdfLicense.SetLicense("Aspose.Pdf.lic");

    // Create a new Document
    Document pdfDocument = new Document
    {
        PageInfo = new PageInfo
        {
            Width = PageSize.A4.Width,
            Height = PageSize.A4.Height,
            Margin = new MarginInfo(0, 0, 0, 0) // Set page margins to zero
        }
    };

    // Add a new page to the PDF document
    var page2 = pdfDocument.Pages.Add();
    page2.PageInfo.Margin = new MarginInfo(0, 0, 0, 0); // Re-confirm page margins

    // Create a floating box business announcment
    FloatingBox testBox = new FloatingBox
    {
        Top = 30,
        Margin = new MarginInfo(0, 10, 0, 0),
        Left = -55,
        Width = 650,
        Padding = new MarginInfo(0, 0, 0, 0),
        BackgroundColor = Color.Green //Comment out when not testing
    };

    TextFragment testBoxText = new TextFragment("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222222222222222222" +
        "22222222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333344444444444444444444444444444444444444444444444444444444444444444444444444444" +
        "4444444444444444444444444444444444444444455555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555666666666666666666666666666666666666666666666666666666666666666666666666666666666666");


    testBox.Paragraphs.Add(testBoxText);

    page2.Paragraphs.Add(testBox);

    DocumentInfoModel docInfo = new DocumentInfoModel
    {
        Document = pdfDocument,
        SectionName = "Today's Business"
    };

    return docInfo;
}
catch (Exception ex)
{
    throw ex;
}

}

here is the result i get

image.png (36.1 KB)

to add extra context:

If i add the text straight onto the document without the floating box I get the same outcome

@cbparl

Instead of the screenshot, would you kindly share the output PDF document for our reference so that we can further proceed with the investigation?

No problem here is the pdf

PreviewSection.pdf (2.5 KB)

Please let me know if you need further information

@cbparl

Please check the output file generated using 24.10 version in our environment and let us know if you notice any issues in it. Also, would you please try using the latest version at your end as well.
floatingBox.pdf (1.9 KB)

Hi

Thank you for looking at my issue. I am currently using the version version 23.11.1 and have done to create other pdfs without this issue.

The pdf you have created with the latest version doesn’t have the same issue however I’m not able to get the latest version at this time (Our procurement for the license is up for review). I was hoping you would be able to identify from the PDF and code I sent you what the problem is as this does seem like a basic action that is preventing me from creating the pdf with aspose.

Could you please re-investigate to identify the problem for the version I currently have? I feel I dont really have a clear insight on what the issue is and it doesnt fill me with confidence the fix suggested is just to update.

@cbparl

We did not change the code snippet that you have shared and used it as it is. Therefore, it does not look like the issue is related to this particular code part. However, if you are passing the PDF through some other code routine or processing after this step, it is possible that output is getting changed there.

We are afraid that we cannot really investigate the issue in older version(s) of the API if it is related to the specific API version. We provide support on the basis of the latest version of the API as per company’s policies.

Please try creating a separate console application that will execute the above code snippet only and see if your existing API version is still creating unexpected results and share that application with us in .zip format.