The HtmlViewOptions class has the following methods to get and set the image width or/and height:
/**
* Max width of an output image in pixels. (When converting single image to HTML only)
*/publicintgetImageMaxWidth();/**
* Max width of an output image in pixels. (When converting single image to HTML only)
*/publicvoidsetImageMaxWidth(intimageMaxWidth);/**
* Max height of an output image in pixels. (When converting single image to HTML only)
*/publicintgetImageMaxHeight();/**
* Max height of an output image in pixels. (When converting single image to HTML only)
*/publicvoidsetImageMaxHeight(intimageMaxHeight);/**
* The width of the output image in pixels. (When converting single image to HTML only)
*/publicintgetImageWidth();/**
* The width of the output image in pixels. (When converting single image to HTML only)
*/publicvoidsetImageWidth(intimageWidth);/**
* The height of an output image in pixels. (When converting single image to HTML only)
*/publicintgetImageHeight();/**
* The height of an output image in pixels. (When converting single image to HTML only)
*/publicvoidsetImageHeight(intimageHeight);
You can set the width and/or height of the output images. Use one of the following methods:
To render a single image, use setImageWidth/setImageHeight methods.
To render multiple images, set setImageMaxWidth/setImageMaxHeight methods. If an image exceeds these limits, it is resized proportionally.
Warning
If you use the setImageWidth/setImageHeight methods, the values specified by thesetImageMaxWidth/setImageMaxHeight methods are ignored.
To call the setImageMaxWidth/setImageMaxHeight methods, follow these steps:
The following code snippet shows how to set the output image size limits:
importcom.groupdocs.viewer.Viewer;importcom.groupdocs.viewer.options.HtmlViewOptions;// ...
try(Viewerviewer=newViewer("sample.jpg")){HtmlViewOptionsviewOptions=HtmlViewOptions.forEmbeddedResources();// Specify the maximum width and height.
viewOptions.setImageMaxWidth(800);viewOptions.setImageMaxHeight(600);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.