I am using Aspose.PDF version 10.1 and I am attempting to create PDF files from an XSL-FO document, and it works, except that the resulting PDF is consideraly larger than it should be.
I attempted to use the "OptimizeResources" but the optimized PDF file ended up being slightly larger then the non-optimized PDF file. I'm using the following code snipet:
// set the name of xsl-fo file
string inFile = @"C:\Temp\Input.fo";
// convert the XSL-FO file to PDF using Aspose load options
Aspose.Pdf.XslFoLoadOptions options = new Aspose.Pdf.XslFoLoadOptions();
options.UseOldXslFoEngine = false;
Aspose.Pdf.Document newDoc = new Aspose.Pdf.Document(inFile, options);
// Optimize the file size by removing unused objects
newDoc.OptimizeResources(new Aspose.Pdf.Document.OptimizationOptions()
{
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
CompressImages = true,
ImageQuality = 10
});
// set the PDF filename
string outputFilename = @"C:\Temp\Output_optimized.pdf";
// save the PDF file
newDoc.Save(outputFilename);
Am I doing something wrong?