Code to reproduce:
var inputFile = new FileInfo(@"Documents/TT11825.pdf");
using (var input = inputFile.OpenRead())
{
using (var document = new PdfDocument(input))
{
var options = new OptimizationOptions
{
RemoveUnusedStreams = true, // <-- this option causes the exception
};
// the next line throws a StackOverflowException
document.OptimizeResources(options);
}
}
The problematic PDF document is attached: TT11825.pdf (1.5 MB)