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);
}
}