Convert XPS to PDF using Aspose.PDF for .NET - Large output PDF file size

Hi,
I’m using Aspose.PDF for .NET (version 20.8.0). I’ve discovered that the output PDF file size is more then two times bigger then the same content generated using virtual printer (eg. PDF Creator). I’m using Aspose.Pdf.Optimization.OptimizationOptions, but size of the document remains the same. Is there any other option to reduce output file size?

@sonar

Would you please share the code snippet and sample input/output files for our reference? We will test the scenario in our environment and address it accordingly.

using (var document = new Aspose.Pdf.Document(xpsPath, new Aspose.Pdf.XpsLoadOptions())) {

	var optimisations = new Aspose.Pdf.Optimization.OptimizationOptions {
		AllowReusePageContent = true,
		LinkDuplcateStreams = true,
		RemoveUnusedObjects = true,
		RemoveUnusedStreams = true
	};

	optimisations.ImageCompressionOptions.CompressImages = true;
	optimisations.ImageCompressionOptions.ImageQuality = 10;

	document.OptimizeResources(optimisations);

	document.Save(outputPath);	
}

pdfcreator.pdf (1.1 MB) - file generated using PDF Creator
with optimisation.pdf (2.9 MB) - file generated using Aspose.PDF with optimisation
without optimisation.pdf (2.9 MB) - file generated using Aspose.PDF without optimisation

@sonar

We noticed that you are generating PDF from XPS file. Would you kindly share that XPS file with us as well? You can share it in .zip format with us. Furthermore, please try to save the PDF document to a memory stream or local path before optimizing it. You can re-initialize the Document object from saved file/stream and then optimize it.

sourcexpsfile.zip (1.9 MB)

Running optimisation on the newly initialised document (after saving it first) doesn’t change the size of the output file.

@sonar

We were able to observe the issue in our environment while testing the scenario with Aspose.PDF for .NET 20.9. The output file size was two times larger even after optimizing it. Therefore, we have logged an issue as PDFNET-48860 in our issue management system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We apologize for the inconvenience.

Hi @asad.ali,
are there any news?
Best regards,
sonar

@sonar

We regret to inform that the earlier logged ticket could not get resolved due to other pending issues in the queue which were logged prior to it. However, we will surely inform you as soon as we have some definite updates regarding ticket resolution. Please give us some time.

We are sorry for the inconvenience.

Hi @asad.ali,
are there any news?
Best regards,
sonar

@sonar

Sadly, there is no news or update about ticket resolution at the moment as investigation could not get completed. We will surely let you know as soon as we make some progress towards ticket resolution. Please spare us some time.

We are sorry for the inconvenience.