Adjust the image size

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 →

To specify the output image size, call the setWidth() and setHeight() methods of the JpgViewOptions or PngViewOptions classes. Specify the value in pixels.

Note
GroupDocs.Viewer applies the aspect ratio automatically applied when you set the setWidth() or setHeight() value.

The following code snippet shows how to set the image width or height.

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.JpgViewOptions;
// ...

try (Viewer viewer = new Viewer("sample.docx")) {
    JpgViewOptions viewOptions = new JpgViewOptions();
    // Specify width and height.
    viewOptions.setWidth(600);
    viewOptions.setHeight(800);

    viewer.view(viewOptions);
}