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, set the Width and Height properties of the JpgViewOptions or PngViewOptions classes. Specify the value in pixels.

Note
GroupDocs.Viewer applies the aspect ratio automatically applied when you set the Width or Height value.

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

using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...

using (Viewer viewer = new Viewer("sample.docx"))
{
    // Create a JPG file.
    JpgViewOptions viewOptions = new JpgViewOptions();
    
    // Specify the width and height.
    viewOptions.Width = 600;
    viewOptions.Height = 800;
    
    viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer("sample.docx")
            ' Create a JPG file.
            Dim viewOptions As JpgViewOptions = New JpgViewOptions()
        
            ' Specify the width and height.
            viewOptions.Width = 600
            viewOptions.Height = 800
        
            viewer.View(viewOptions)
        End Using
    End Sub
End Module

sample.docx is the sample file used in this example. Click here to download it.

p_1.jpg (54 KB)
p_2.jpg (62 KB)
p_3.jpg (65 KB)
p_4.jpg (65 KB)
p_5.jpg (44 KB)

Download full output