Free Support Forum - aspose.com

Reduce pdf size

I generate pdfs using the Aspose.pdf library. I combine many documents together to form one.
I need to reduce the size of the final document. I use the following code to OptimizeResources. An example it only reduces from 4641kb to 4121kb. If I use Adobe DC to manually reduce the size it shrinks down to 1734kb. How can I get it to shrink down to the 1734kb?

Dim pdf As Document = New Document(dataDir & “testdoc.pdf”)
pdf.OptimizeResources(New Document.OptimizationOptions() With {
.LinkDuplcateStreams = True,
.RemoveUnusedObjects = True,
.AllowReusePageContent = True,
.RemoveUnusedStreams = True,
.UnembedFonts = False,
.CompressImages = True,
.ImageQuality = 10,
.ResizeImages = True
})
pdf.Save(dataDir & “testdoc_out2.pdf”)

@PPIB

Thanks for contacting support.

It would be helpful if you can please share some sample PDF documents with us. We will test the scenario in our environment and address it accordingly.

FullPolicy.pdf (4.5 MB)
Attached is a document, thank you!

@PPIB

Thanks for sharing the sample document.

The document which you have shared has many embedded fonts due to which its size is large. While optimizing the PDF document, you were keeping those fonts which was why the decrease in size was not significant. Please try to set UnembedFonts property as true and optimize PDF. We have attached sample output generated by using suggested settings.

compressed.pdf (1.1 MB)

In case of further assistance, please feel free to let us know.

That worked. Thank you!