Provides options for rendering documents into HTML format.
The HtmlViewOptions class encapsulates additional settings and parameters that can be used to control the rendering of documents into HTML format in the GroupDocs.Viewer component.
HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources();
options.setExcludeFonts(true);
options.setFontsToExclude(Arrays.asList("font-name"));
try (Viewer viewer = new Viewer("document.docx")) {
viewer.view(options);
// Use the viewer object for further operations
}
Sets permission to remove the JavaScript source code from the links in resultant HTML documents, when rendering input documents, which have the scripts.
Initializes a new instance of the HtmlViewOptions class.
CREATE_PAGE_STREAM
public static final String CREATE_PAGE_STREAM
FILE_PATH_FORMAT
public static final String FILE_PATH_FORMAT
isRenderResponsive()
public final boolean isRenderResponsive()
Determines whether responsive rendering is enabled. Responsive web pages render well on devices with different screen sizes.
Responsive design aims to make web pages render well on a variety of devices. To render with a responsive layout, set this property to true. For code example, see the documentation.
Returns:
boolean - true if responsive rendering is enabled, false otherwise.
setRenderResponsive(boolean value)
public final void setRenderResponsive(boolean value)
Sets whether responsive rendering is enabled. Responsive web pages render well on devices with different screen sizes.
Responsive design aims to make web pages render well on a variety of devices. To render with a responsive layout, set this property to true. For code example, see the documentation.
Parameters:
Parameter
Type
Description
value
boolean
true to enable responsive rendering, false to disable it.
isMinify()
public final boolean isMinify()
Checks if HTML content and HTML resources minification is enabled.
Compression of the output content (HTML, CSS, and SVG) is one of the ways to optimize the HTML file. To do this, set this property to true. For code example, see the documentation.
Returns:
boolean - true if minification is enabled, false otherwise.
setMinify(boolean value)
public final void setMinify(boolean value)
Sets whether HTML content and HTML resources minification is enabled.
Compression of the output content (HTML, CSS, and SVG) is one of the ways to optimize the HTML file. To do this, set this property to true. For code example, see the documentation.
Parameters:
Parameter
Type
Description
value
boolean
true to enable minification, false to disable.
isRenderToSinglePage()
public boolean isRenderToSinglePage()
Enables rendering an entire document to one HTML file.
Returns the maximum width of an output image in pixels.
Note: This value is used when converting a single image to HTML. For details and code example, see the documentation.
Returns:
int - the maximum width of an output image.
setImageMaxWidth(int imageMaxWidth)
public void setImageMaxWidth(int imageMaxWidth)
Sets the maximum width of an output image in pixels.
Note: This value is used when converting a single image to HTML. For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
imageMaxWidth
int
The maximum width of an output image.
getImageMaxHeight()
public int getImageMaxHeight()
Gets the maximum height of an output image in pixels.
Note: This option applies when converting a single image to HTML. It specifies the maximum height of the output image. For details and code example, see the documentation.
Returns:
int - the maximum height of an output image.
setImageMaxHeight(int imageMaxHeight)
public void setImageMaxHeight(int imageMaxHeight)
Sets the maximum height of an output image in pixels.
Note: This option applies when converting a single image to HTML. It specifies the maximum height of the output image. For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
imageMaxHeight
int
The maximum height of an output image.
getImageWidth()
public int getImageWidth()
Gets the width of the output image in pixels.
Note: This value is applicable only when converting a single image to HTML. For details and code example, see the documentation.
Returns:
int - the width of the output image.
setImageWidth(int imageWidth)
public void setImageWidth(int imageWidth)
Sets the width of the output image in pixels.
Note: This value is applicable only when converting a single image to HTML. For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
imageWidth
int
The width of the output image.
getImageHeight()
public int getImageHeight()
Gets the height of the output image in pixels when converting a single image to HTML.
For details and code example, see the documentation.
Returns:
int - the height of the output image in pixels.
setImageHeight(int imageHeight)
public void setImageHeight(int imageHeight)
Sets the height of the output image in pixels when converting a single image to HTML.
For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
imageHeight
int
The height of the output image in pixels.
isForPrinting()
public final boolean isForPrinting()
Checks if the output HTML should be optimized for printing.
Enable this option to convert the output HTML pages to the vector SVG format. For details and code example, see the documentation.
Returns:
boolean - true if the output HTML should be optimized for printing, false otherwise.
setForPrinting(boolean value)
public final void setForPrinting(boolean value)
Sets whether the output HTML should be optimized for printing.
Enable this option to convert the output HTML pages to the vector SVG format. For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
value
boolean
true to optimize the output HTML for printing, false otherwise.
isExcludeFonts()
public final boolean isExcludeFonts()
Determines whether to exclude fonts from the HTML document.
By default, GroupDocs.Viewer embeds the fonts used in the document into HTML. To prevent it, set this property to true. For details and code example, see the documentation.
Returns:
boolean - true if fonts should be excluded, false otherwise.
setExcludeFonts(boolean value)
public final void setExcludeFonts(boolean value)
Sets whether to exclude fonts from the HTML document.
By default, GroupDocs.Viewer embeds the fonts used in the document into HTML. To prevent it, set this property to true. For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
value
boolean
true to exclude fonts, false otherwise.
getFontsToExclude()
public final List<String> getFontsToExclude()
Retrieves the list of font names to exclude from the HTML document.
This option is supported for presentations only. Including fonts in the HTML document improves the stability of the output view but increases the rendering result’s size. Use this option to find a compromise between stability and output size. Include font names that are popular and installed on most systems.
Note: Please note that this property is active only when the ExcludeFonts (#isExcludeFonts().isExcludeFonts()/#setExcludeFonts(boolean).setExcludeFonts(boolean)) option is disabled. For details and code example, see the documentation.
Returns:
java.util.List<java.lang.String> - the list of font names to exclude from the HTML document.
setFontsToExclude(List value)
public final void setFontsToExclude(List<String> value)
Sets the list of font names to exclude from the HTML document.
This option is supported for presentations only. Including fonts in the HTML document improves the stability of the output view but increases the rendering result’s size. Use this option to find a compromise between stability and output size. Include font names that are popular and installed on most systems.
Note: Please note that this property is active only when the ExcludeFonts (#isExcludeFonts().isExcludeFonts()/#setExcludeFonts(boolean).setExcludeFonts(boolean)) option is disabled. For details and code example, see the documentation.
Parameters:
Parameter
Type
Description
value
java.util.List<java.lang.String>
The list of font names to exclude from the HTML document.
isRemoveJavaScript()
public final boolean isRemoveJavaScript()
Allows to remove the JavaScript source code from the links in resultant HTML documents, when rendering input documents, which have the scripts. By default is enabled (true).
For details about removing JavaScript, see the documentation.
Returns:
boolean
setRemoveJavaScript(boolean value)
public void setRemoveJavaScript(boolean value)
Sets permission to remove the JavaScript source code from the links in resultant HTML documents, when rendering input documents, which have the scripts. By default is enabled (true).
For details about removing JavaScript, see the documentation.
Parameters:
Parameter
Type
Description
value
boolean
getDocumentSavingCallback()
public IDocumentSavingCallback getDocumentSavingCallback()
Retrieves the callback used to estimate the saving progress of a Words or Email document.
Returns:
com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback - the callback used to estimate the document saving progress.
public static HtmlViewOptions forEmbeddedResources(CreatePageStream createPageStream)
Initializes a new instance of the HtmlViewOptions class for rendering into HTML with embedded resources.
Note: The method takes a CreatePageStream parameter, which is a method used to instantiate a stream for writing output page data. For the code example, see the documentation.
public static HtmlViewOptions forExternalResources(CreatePageStream createPageStream, CreateResourceStream createResourceStream, CreateResourceUrl createResourceUrl)
Initializes a new instance of the HtmlViewOptions class for rendering into HTML with external resources.
Note: This method should be used when rendering HTML with external resources, such as CSS and JavaScript files. For the code example, see the documentation.