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!

Hello, first of all, the method you mentioned is really useful, but put the compressed pdf file on the mac computer, and use the preview or browser to open it and you will find that the text inside becomes… Then copy and paste these points to txt, but you can see the original text

@kangkang

We are afraid that we were unable to understand about the issue correctly. Can you please elaborate a bit more about it by sharing some code snippet, sample file and screenshots?

this is my code
optimizationOptions.LinkDuplcateStreams = true;
optimizationOptions.RemoveUnusedObjects = true;
optimizationOptions.RemoveUnusedStreams = true;
optimizationOptions.AllowReusePageContent = true;
optimizationOptions.UnembedFonts = true;
imageCompressionOptions.CompressImages = true;
imageCompressionOptions.ImageQuality = nQuality;
imageCompressionOptions.ResizeImages = true;
imageCompressionOptions.MaxResolution = nResolution;
return optimizationOptions;

Below is the comparison between opening in win after compression and opening on macos

open on win
image.png (161.0 KB)
open on mac with preview
image.png (29.2 KB)

Is it because of the reason for removing the embedded font, is there a way to solve this problem, I open it with professional software on the mac will display the original text normally

@kangkang

Yes, this can be the possible reason. Also, please make sure that all Windows Essential Fonts are properly installed in the MacOS and try not to unembed fonts during optimization. In case issue still occurs, please share your sample PDF with us so that we can further proceed accordingly.

ok,thank you