Compress and optimize PDF files using PDFNet SDK

Q: I got one issue when I use PDFNet to compress PDF files.
Is it possible to let PDFNet tell me what the original PDF file
quality is? If that’s possible, then I could dynamically set quality
level when compressing a file. Saying if the uploaded file is in good
quality, I set quality level to 1; otherwise set the quality level to
4.
Part of the code as following:
pdftron.PDF.Optimizer.ImageSettings grayscale_image_settings = new
pdftron.PDF.Optimizer.ImageSettings();
grayscale_image_settings.SetCompressionMode(pdftron.PDF.Optimizer.ImageSettings.CompressionMode.e_jpeg);
            grayscale_image_settings.SetQuality(1);
            grayscale_image_settings.ForceChanges(true);
            grayscale_image_settings.ForceRecompression(true);
            grayscale_image_settings.SetImageDPI(150, 150);
--------------

A: You could use PDFNet to figure out the image resolution and filters
of individual images as described in the following articles:

http://groups.google.com/group/pdfnet-sdk/t/eefd5c8373c19608
http://groups.google.com/group/pdfnet-sdk/t/6950ce1219ae1faf
http://groups.google.com/group/pdfnet-sdk/t/5b50d2c842347087

However there is no single parameter in PDF describing the overall
quality of the document.

The way ‘pdftron.PDF.Optimizer’ works if that you provide specific
quality parameters (e.g. image resolution, compression, etc.) for the
document. If a source image in PDF has a lower quality than the
provided quality parameter it will not be resampled or downsized. Only
images with the higher resolution that the are downsized.

You may want to comment out ForceChanges(true) since in some cases it
could lead to expansion in file size.

Please keep in mind that besides image compression and resampling the
Optimizer can help in many other ways (such as removing duplicate
fonts, images and other objects, font sub-setting, etc.).