Hello,
In order to lighten the weight of PDFs in our database, we want to use Aspose.Pdf optimization.
We use Aspose.PDF .NET.
However, during our tests, we observed very high memory consumption, around 35MB of memory per MB of PDF in 64bit mode. Multiplied by 5 if used in a 32bit context (Sample : 5Mo pdf uses 900MB of memory in a 32 bit context !!! It’s hot!)
Technical constraints force us to use a 32 bit application, which is a concern for us. We therefore plan to go through another tool in 64bit, but the memory consumption remains high, is this normal?
Code C# with this pdf : https://inter-static.skywatcher.com/upfiles/en_download_caty01461862245.pdf (6.9MB => Memory usage : 250MB)
using Aspose.Pdf;
using Aspose.Pdf.Optimization;
using System;
namespace TestAsposePdfOptimisation
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Optimisation PDF !");
const String fileName = "C:\\SI\\en_download_caty01461862245.pdf";
const String fileNameOpti = "C:\\SI\\en_download_caty01461862245_opti.pdf";
const String asposeLicence = "S:\\partage-dev\\Composants\\Aspose.Total.NET.lic";
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(asposeLicence);
var optiOptions = new OptimizationOptions();
optiOptions.RemoveUnusedObjects = true;
optiOptions.RemoveUnusedStreams = true;
optiOptions.LinkDuplcateStreams = true;
optiOptions.AllowReusePageContent = true;
var imgCompressionOptions = optiOptions.ImageCompressionOptions;
imgCompressionOptions.CompressImages = true;
imgCompressionOptions.ImageQuality = 50;
imgCompressionOptions.ResizeImages = true;
imgCompressionOptions.MaxResolution = 150;
Console.WriteLine("Chargement pdf...");
var pdfDocument = new Aspose.Pdf.Document(fileName);
Console.WriteLine("Avant optimisation...");
pdfDocument.OptimizeResources(optiOptions);
Console.WriteLine("Apres optimisation...");
pdfDocument.Save(fileNameOpti);
Console.WriteLine("Fin optimisation PDF !");
Console.WriteLine(".");
}
}
}