I am building a PDF doc with images. The doc can have up to 3 images on one page. There is multiple pages. It will run in about 6.7 secs with out the images and 291 seconds when I add the images. The images are “text”. I need them formatted to a dynamic size and converting pdfs to png seemed the easiest way to manage the text format. I have a method that calls the following code:
try
{
var optimizeOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
//{
// RemoveUnusedObjects = false,
// RemoveUnusedStreams = true,
// LinkDuplcateStreams = true,
// AllowReusePageContent = true,
// UnembedFonts = false,
// MaxResoultion = 50,
//};
optimizeOptions.ImageCompressionOptions.ImageQuality = 50;
optimizeOptions.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
optimizeOptions.ImageCompressionOptions.CompressImages = true;
doc.OptimizeResources(optimizeOptions);
After this code is where I add the requested images. There is a little bit of logic to determine which image to add and then it calls:
doc.Pages[ii].AddImage(PdfFolder + name, rec);
I am not sure how the optimization works. Am I using it correctly? Where should I place this code in relation to the doc and images? Is there a better way than what I am doing?