Adding an Image as a Paragraph causes infinite processing until out of memory

I am converting images to PDFs. When using specific settings, like a 2cm Margin this causes the call of Aspose.PDF.Document.Save or Aspose.PDF.Document.ProcessParagraphs to process infinitely, until the program crashes when running out of memory. This is the simplest code example where the error occurs:

using Aspose.Pdf;
using System.Reflection;

var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
const double POINTS_PER_CENTIMETER = 28.3465;
var margins = 2 * POINTS_PER_CENTIMETER;

var document = new Document();
var page = document.Pages.Add();
page.PageInfo.Margin = new MarginInfo(
    margins,
    margins,
    margins,
    margins
     );

var image = new Image
{
    ImageStream = File.OpenRead(Path.Combine(directory, "test.png")),
    HorizontalAlignment = HorizontalAlignment.Center,
    VerticalAlignment = VerticalAlignment.Center,
};
var width = image.BitmapSize.Width;
var height = image.BitmapSize.Height;
page.SetPageSize(width + 2 * margins, height + 2 * margins);
page.Paragraphs.Add(image);

document.Save(Path.Combine(directory, "test.pdf"));

I am pretty sure this happens due to the margins and irrespective of the used image. Setting POINTS_PER_CENTIMETER to 25, for example, does not cause the problem. I am relying on this precision, however, to get proper DIN A4 page sizes.

Well this is not an issue for me, adding a point tolerance to the margins makes the issue not occur. I simply wanted to report the issue.

@SvenFPDBS
Thank you for writing to us about the issue.
There have been recent changes to the library related to such cases - are you using the latest version (25.03)?
Could you please attach the test.png file used in the attached code snippet so that we can reproduce and investigate the issue.

Yes, I am currently using 25.3.0.

test.png (8,4 KB)

The issue occurs with this test image.

@SvenFPDBS
Yes, the problem remains, even with the latest version. Thanks for writing to us - I will create a task for the development team.

@SvenFPDBS
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-59706

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.