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
Part of the code as following:
pdftron.PDF.Optimizer.ImageSettings grayscale_image_settings = new
A: You could use PDFNet to figure out the image resolution and filters
of individual images as described in the following articles:
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.).