We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Stackoverflow on document.OptimizeResources(options)

Hello Aspose,

I have a problem in production
When i optimise a specifique PDF, application crash with a stackoverflow on document.OptimizeResources(options);
2020-07-03 Offre services Visio-audio conférence & vote à distance.pdf (151.2 KB)

an exemple of my code :

public static void Main(string[] args)
{
Aspose.Pdf.License asposeLicence = new Aspose.Pdf.License();
asposeLicence.SetLicense(“Aspose.Total.lic”);

string filename;
if (args == null || args.Length == 0)
{
throw new ArgumentNullException(“file is missing”);
}
else
{
filename = args[0];
}

FileInfo fichier = new FileInfo(filename);
if (!fichier.Exists)
{
Console.WriteLine($“file {fichier.FullName} not found”);
}

Console.WriteLine($“Test file {fichier.FullName}”);
using (Document document = new Document(fichier.FullName))
{
OptimisationPdf(document, true);
document.Save(fichier.FullName);
}

Console.WriteLine();
Console.WriteLine(“End”);
}

private static void OptimisationPdf(Document document, bool pageContent)
{
if (document is null)
{
return;
}

var options = new OptimizationOptions
{
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
AllowReusePageContent = pageContent,
UnembedFonts = true,
};

try
{
document.OptimizeResources(options);
}
catch (Exception ex)
{
Console.WriteLine(“optimisation exception”, ex);
}
}

@admin.grenoble

The issue you mentioned was reproducible at our side while testing the scenario with Aspose.PDF for .NET 21.1. Therefore, it has been logged as PDFNET-49264 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-49264) have been fixed in Aspose.PDF for .NET 21.8.