Adjust the image size
Leave feedback
To specify the output image size, call the setWidth() and setHeight() methods of the JpgViewOptions or PngViewOptions classes. Specify the value in pixels.
NoteGroupDocs.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);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.