We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF file size too large

i used Aspose.pdf to create pdf files and the file size is 5 times than the my existing system.How can i compress the file

Hi Adwait,


Thanks for your inquiry. Please check following code snippet for optimizing the PDF document. Hopefully it will serve the purpose. If issue persist then please share your source document here. So we will test it at our end and will provide you more information accordingly.

Aspose.Pdf.Document pdffile = new Aspose.Pdf.Document(“input.pdf”);
// optimize the file size
pdffile.OptimizeResources(new Document.OptimizationOptions() { RemoveUnusedStreams = true, RemoveUnusedObjects = true, LinkDuplcateStreams = true });
// save updated file
pdffile.Save(myDir + “output.pdf”);

Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal,

I first created the PDF using the Aspose.Pdf.Generator and then used the code you provided to optimize, the file size was reduced to half its original size.

Thanks a lot that helped

Adwait Sharma