A question regarding PDF Optimization

Q: With this code…
… code to render to PDFDoc …

If Optimize Then
Optimizer.Optimize(mDoc)
End If
mDoc.Save(mFileName, SaveOptions.e_linearized Or
SaveOptions.e_remove_unused)

I am rendering an output PDF document. I get identically sized output,
regardless of calling the optimizer or not.

This must mean that either the optimizer is AUTOMATICALLY invoked for
me on PDFDoc.Save call, or else, I am not getting the effect of the
optimizer, perhaps because I am calling it incorrectly.

Still, I notice my output file size is 11% smaller than when produced
with PDFNet V.5.2


A: I suspect that in your case the document does not contain images
with high dpi and the optimizer text settings are not used by
default. However, by changing the optimizer options it can be
possible to reduce the file size. Image quality reduction options
will only be effective if there are enough images in the document.

For Example:

Dim image_settings As New Optimizer.ImageSettings
Dim mono_settings As New Optimizer.MonoImageSettings
Dim text_settings As New Optimizer.TextSettings
Dim opt_settings As New Optimizer.OptimizerSettings

’ These options should not reduce viewing quality (with the exception
of removing font hinting)
mono_settings.ForceRecompression(True)
text_settings.SubsetFonts(True)

’ Some quality reduction for color images
image_settings.ForceRecompression(True)
image_settings.SetCompressionMode(Optimizer.ImageSettings.CompressionMode.e_
jpeg)

’ Further quality reduction options
’ (these may reduce image quality too much)
’ image_settings.SetImageDPI(96, 72)
’ mono_settings.SetImageDPI(200, 144)
’ image_settings.SetQuality(1)

opt_settings.SetGrayscaleImageSettings(image_settings)
opt_settings.SetColorImageSettings(image_settings)
opt_settings.SetMonoImageSettings(mono_settings)
opt_settings.SetTextSettings(text_settings)

Optimizer.Optimize(doc, opt_settings)

The 11% reduction in file size experienced when switching versions is
most likely caused by the compressed object stream improvement that
was introduced in recent versions of PDFNet.