Using the following code on the attached PDF causes a StackOverflowException on Aspose.PDF for .NET 26.2:
var pdf = new Document("input.pdf");
var absorber = new ImagePlacementAbsorber();
absorber.IsReadOnlyMode = true; // CAUSES STACK OVERFLOW
pdf.Pages[1].Accept(absorber);
Removing the 3rd line (i.e. leaving IsReadOnlyMode = false) avoids the error.
Thanks for sharing the sample. Based on your description, here is a likely technical approach for Aspose.PDF.
ImagePlacementAbsorber walks the page content tree to collect image objects. In version 26.2 the implementation enters an infinite recursion when IsReadOnlyMode is set to true and the page contains certain nested XObject/image structures (the sample PDF triggers this). The recursion eventually overflows the call stack, producing the StackOverflowException.
A quick workaround is to keep IsReadOnlyMode set to false (the default) or to use a newer Aspose.PDF for .NET build where the bug has been fixed (e.g., 26.3+). If you must stay on 26.2, you can avoid the absorber on pages that contain complex XObjects, or manually extract images via pdf.Pages[1].Resources.Images instead of the absorber.
var pdf = new Document("input.pdf");
// Work‑around: keep read‑only mode disabled
var absorber = new ImagePlacementAbsorber(); // IsReadOnlyMode = false (default)
pdf.Pages[1].Accept(absorber);
Clarifying questions
Does the PDF contain nested image XObjects, form XObjects, or other resources that could create a deep content‑tree (e.g., images inside form fields or templates)?
Have you tested the same code with a newer Aspose.PDF for .NET version (e.g., 26.3 or later) to see if the exception is still reproduced?