Set image resolution

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

On this page

If the output PDF file contains images, you can reduce its resolution.

To allow changing the image resolution, set the setCompressImages() and setResizeImages() setters to true in the PdfOptimizationOptions. The GroupDocs.Viewer compresses all images in the file. The setMaxResolution() property determines the maximum resolution.

The following code snippet shows how to reduce image resolution in the file:

try (Viewer viewer = new Viewer("sample.docx")) {
    PdfViewOptions viewOptions = new PdfViewOptions();
    PdfOptimizationOptions optimizationOptions = new PdfOptimizationOptions();
    
    optimizationOptions.setCompressImages(true);
    optimizationOptions.setImageQuality(50);
    optimizationOptions.setResizeImages(true);
    optimizationOptions.setMaxResolution(100);
     
    viewOptions.setPdfOptimizationOptions(optimizationOptions);
    viewer.view(viewOptions);
}

The following image demonstrates the result:

Set max resolution

On this page