public class HtmlViewOptions extends ViewOptions
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.
For details, see the topic and its children.
Example usage:
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
}
Viewer| Modifier and Type | Field and Description |
|---|---|
static String |
CREATE_PAGE_STREAM |
static String |
FILE_PATH_FORMAT |
| Modifier and Type | Method and Description |
|---|---|
static HtmlViewOptions |
forEmbeddedResources()
Initializes a new instance of the
HtmlViewOptions class. |
static HtmlViewOptions |
forEmbeddedResources(CreatePageStream createPageStream)
Initializes a new instance of the
HtmlViewOptions class for rendering into HTML with embedded resources. |
static HtmlViewOptions |
forEmbeddedResources(CreatePageStream createPageStream,
ReleasePageStream releasePageStream)
Initializes a new instance of the
HtmlViewOptions class for rendering into HTML with embedded resources. |
static HtmlViewOptions |
forEmbeddedResources(PageStreamFactory pageStreamFactory)
Initializes a new instance of the
HtmlViewOptions class for rendering into HTML with embedded resources. |
static HtmlViewOptions |
forEmbeddedResources(Path filePathFormat)
Initializes a new instance of the
HtmlViewOptions class. |
static HtmlViewOptions |
forEmbeddedResources(String filePathFormat)
Initializes a new instance of the
HtmlViewOptions class. |
static HtmlViewOptions |
forExternalResources()
Initializes new instance of
HtmlViewOptions class. |
static HtmlViewOptions |
forExternalResources(CreatePageStream createPageStream,
CreateResourceStream createResourceStream,
CreateResourceUrl createResourceUrl)
Initializes a new instance of the
HtmlViewOptions class for rendering into HTML with external resources. |
static HtmlViewOptions |
forExternalResources(CreatePageStream createPageStream,
CreateResourceStream createResourceStream,
CreateResourceUrl createResourceUrl,
ReleasePageStream releasePageStream,
ReleaseResourceStream releaseResourceStream)
Initializes a new instance of the
HtmlViewOptions class for rendering into HTML with external resources. |
static HtmlViewOptions |
forExternalResources(PageStreamFactory pageStreamFactory,
ResourceStreamFactory resourceStreamFactory)
Initializes a new instance of the
HtmlViewOptions class for rendering into HTML with external resources. |
static HtmlViewOptions |
forExternalResources(String filePathFormat,
String resourceFilePathFormat,
String resourceUrlFormat)
Initializes a new instance of the
HtmlViewOptions class. |
com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback |
getDocumentSavingCallback()
Retrieves the callback used to estimate the saving progress of a Words or Email document.
|
List<String> |
getFontsToExclude()
Retrieves the list of font names to exclude from the HTML document.
|
int |
getImageHeight()
Gets the height of the output image in pixels when converting a single image to HTML.
|
int |
getImageMaxHeight()
Gets the maximum height of an output image in pixels.
|
int |
getImageMaxWidth()
Returns the maximum width of an output image in pixels.
|
int |
getImageWidth()
Gets the width of the output image in pixels.
|
boolean |
isExcludeFonts()
Determines whether to exclude fonts from the HTML document.
|
boolean |
isForPrinting()
Checks if the output HTML should be optimized for printing.
|
boolean |
isMinify()
Checks if HTML content and HTML resources minification is enabled.
|
boolean |
isRenderResponsive()
Determines whether responsive rendering is enabled.
|
boolean |
isRenderToSinglePage()
Enables rendering an entire document to one HTML file.
|
void |
setDocumentSavingCallback(com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback documentSavingCallback)
Sets the callback used to estimate the saving progress of a Words or Email document.
|
void |
setExcludeFonts(boolean value)
Sets whether to exclude fonts from the HTML document.
|
void |
setFontsToExclude(List<String> value)
Sets the list of font names to exclude from the HTML document.
|
void |
setForPrinting(boolean value)
Sets whether the output HTML should be optimized for printing.
|
void |
setImageHeight(int imageHeight)
Sets the height of the output image in pixels when converting a single image to HTML.
|
void |
setImageMaxHeight(int imageMaxHeight)
Sets the maximum height of an output image in pixels.
|
void |
setImageMaxWidth(int imageMaxWidth)
Sets the maximum width of an output image in pixels.
|
void |
setImageWidth(int imageWidth)
Sets the width of the output image in pixels.
|
void |
setMinify(boolean value)
Sets whether HTML content and HTML resources minification is enabled.
|
void |
setRenderResponsive(boolean value)
Sets whether responsive rendering is enabled.
|
void |
setRenderToSinglePage(boolean renderSinglePage)
Enables rendering an entire document to one HTML file.
|
getPageRotations, getWatermark, isPageRotationsInitialized_Internal, rotatePage, setWatermarkgetArchiveOptions, getCadOptions, getDefaultFontName, getEmailOptions, getMailStorageOptions, getOutlookOptions, getPdfOptions, getPresentationOptions, getProjectManagementOptions, getSpreadsheetOptions, getTextOptions, getVisioRenderingOptions, getWebDocumentOptions, getWordProcessingOptions, isCadOptionsInitialized_Internal, isRenderComments, isRenderHiddenPages, isRenderNotes, setArchiveOptions, setCadOptions, setDefaultFontName, setEmailOptions, setMailStorageOptions, setOutlookOptions, setPdfOptions, setPresentationOptions, setProjectManagementOptions, setRenderComments, setRenderHiddenPages, setRenderNotes, setSpreadsheetOptions, setTextOptions, setVisioRenderingOptions, setWebDocumentOptions, setWordProcessingOptionspublic static final String CREATE_PAGE_STREAM
public static final String FILE_PATH_FORMAT
public static HtmlViewOptions forEmbeddedResources()
Initializes a new instance of the HtmlViewOptions class.
For the code example, see the documentation.
HtmlViewOptions class.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.
createPageStream - The method that instantiates a stream used to write output page data.HtmlViewOptions class for rendering into HTML with embedded resources.CreatePageStreampublic static HtmlViewOptions forEmbeddedResources(CreatePageStream createPageStream, ReleasePageStream releasePageStream)
Initializes a new instance of the HtmlViewOptions class for rendering into HTML with embedded resources.
For the code example, see the documentation.
createPageStream - The method that instantiates a stream used to write output page data.releasePageStream - The method that releases the stream created by the method assigned to the createPageStream parameter.HtmlViewOptions class for rendering into HTML with embedded resources.IllegalArgumentException - If the createPageStream or releasePageStream is null.CreatePageStream,
ReleasePageStreampublic static HtmlViewOptions forEmbeddedResources(PageStreamFactory pageStreamFactory)
Initializes a new instance of the HtmlViewOptions class for rendering into HTML with embedded resources.
For the code example, see the documentation.
pageStreamFactory - The factory that implements methods for creating and releasing the output page stream.HtmlViewOptions class for rendering into HTML with embedded resources.IllegalArgumentException - If the pageStreamFactory is null.PageStreamFactorypublic static HtmlViewOptions forEmbeddedResources(Path filePathFormat)
Initializes a new instance of the HtmlViewOptions class.
For the code example, see the documentation.
filePathFormat - The file path format, e.g., 'page_{0}.html'.HtmlViewOptions class.IllegalArgumentException - If filePathFormat is null.public static HtmlViewOptions forEmbeddedResources(String filePathFormat)
Initializes a new instance of the HtmlViewOptions class.
For the code example, see the documentation.
filePathFormat - The file path format, e.g., 'page_{0}.html'.HtmlViewOptions class.IllegalArgumentException - If filePathFormat is null or empty.public static HtmlViewOptions forExternalResources()
Initializes new instance of HtmlViewOptions class.
IllegalArgumentException - Thrown when the filePathFormat is null or empty.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.
createPageStream - The method that instantiates the stream used to write output page data.createResourceStream - The method that releases the stream created by the createPageStream method.createResourceUrl - The method that creates the URL for the HTML resource.HtmlViewOptions class for rendering into HTML with external resources.IllegalArgumentException - If createPageStream is null.IllegalArgumentException - If createResourceStream is null.IllegalArgumentException - If createResourceUrl is null.public static HtmlViewOptions forExternalResources(CreatePageStream createPageStream, CreateResourceStream createResourceStream, CreateResourceUrl createResourceUrl, ReleasePageStream releasePageStream, ReleaseResourceStream releaseResourceStream)
Initializes a new instance of the HtmlViewOptions class for rendering into HTML with external resources.
For the code example, see the documentation.
createPageStream - The method that instantiates the stream used to write output page data.createResourceStream - The method that instantiates the stream used to write output HTML resource data.createResourceUrl - The method that creates the URL for the HTML resource.releasePageStream - The method that releases the stream created by the createPageStream method.releaseResourceStream - The method that releases the stream created by the createResourceStream method.HtmlViewOptions class for rendering into HTML with external resources.IllegalArgumentException - Thrown when createPageStream, createResourceStream, createResourceUrl, releasePageStream or releaseResourceStream is null.public static HtmlViewOptions forExternalResources(PageStreamFactory pageStreamFactory, ResourceStreamFactory resourceStreamFactory)
Initializes a new instance of the HtmlViewOptions class for rendering into HTML with external resources.
For the code example, see the documentation.
pageStreamFactory - The factory that implements methods for creating and releasing the output page stream.resourceStreamFactory - The factory that implements methods for creating resource URLs and instantiating/releasing the output HTML resource stream.HtmlViewOptions class for rendering into HTML with external resources.IllegalArgumentException - Thrown when pageStreamFactory or resourceStreamFactory is null.public static HtmlViewOptions forExternalResources(String filePathFormat, String resourceFilePathFormat, String resourceUrlFormat)
Initializes a new instance of the HtmlViewOptions class.
For the code example, see the documentation.
filePathFormat - The file path format, e.g., 'page_{0}.html'.resourceFilePathFormat - The resource file path format, e.g., 'page_{0}/resource_{1}'.resourceUrlFormat - The resource URL format, e.g., 'page_{0}/resource_{1}'.IllegalArgumentException - Thrown when filePathFormat, resourceFilePathFormat or resourceUrlFormat is null or empty.public com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback getDocumentSavingCallback()
Retrieves the callback used to estimate the saving progress of a Words or Email document.
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()/setExcludeFonts(boolean)) option is disabled.
For details and code example, see the documentation.
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.
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.
public int getImageMaxWidth()
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.
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.
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 if fonts should be excluded, false otherwise.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.
true if the output HTML should be optimized for printing, false otherwise.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 if minification is enabled, false otherwise.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 if responsive rendering is enabled, false otherwise.public boolean isRenderToSinglePage()
See the following topics for more information:
Example:
try (final Viewer viewer = new Viewer("invoice.docx")) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewOptions.setRenderToSinglePage(true);
viewer.view(viewOptions);
}
public void setDocumentSavingCallback(com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback documentSavingCallback)
Sets the callback used to estimate the saving progress of a Words or Email document.
documentSavingCallback - The callback used to estimate the document saving progress.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
value - true to exclude fonts, false otherwise.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()/setExcludeFonts(boolean)) option is disabled.
For details and code example, see the documentation.
value - The list of font names to exclude from the HTML document.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.
value - true to optimize the output HTML for printing, false otherwise.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.
imageHeight - The height of the output image in pixels.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.
imageMaxHeight - The maximum height of an output image.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.
imageMaxWidth - The maximum width of an output image.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.
imageWidth - The width of the output image.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
value - true to enable minification, false to disable.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
value - true to enable responsive rendering, false to disable it.public void setRenderToSinglePage(boolean renderSinglePage)
See the following topics for more information:
Example:
try (final Viewer viewer = new Viewer("invoice.docx")) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewOptions.setRenderToSinglePage(true);
viewer.view(viewOptions);
}
Copyright © 2024. All rights reserved.