Reduce image quality

On this page

If the output PDF file contains images, you can reduce its size using image compression.

To enable image compression, set the CompressImages property to true. The GroupDocs.Viewer compresses all images in the file.

The ImageQuality property determines the compression ratio. It is a quality value in percent. 100% means original quality.

The following code snippet shows how to compress images in the file:

using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization;
// ...

using (var viewer = new Viewer("sample.docx"))
{
    PdfViewOptions viewOptions = new PdfViewOptions();
    viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions()
    {
        CompressImages = true,
        ImageQuality = 50
    };
     
    viewer.View(viewOptions);
}

The following image demonstrates the result:

Reduce image quality

On this page