com.groupdocs.viewer.converter.options

Class HtmlOptions



  • public class HtmlOptions
    extends RenderOptions

    Provides options for rendering documents as HTML.

    • Constructor Detail

      • HtmlOptions

        public HtmlOptions()

        Initializes a new instance of HtmlOptions object.

    • Method Detail

      • setEmbedResources

        public void setEmbedResources(boolean value)

        Indicates whether to embed resources into HTML or not.

        Note:
        To save resources (fonts, images and CSS) into a separate file, enable the use of cache and disable resource embedding as shown in example.

        Example:
        The following example demonstrates how to separate resources from HTML.

         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         String guid = "C:\storage\document.doc";
         HtmlOptions options = new HtmlOptions();
         options.setEmbedResources(false);
        
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - true if this instance is resources embedded; otherwise, false.
      • setEnableMinification

        public void setEnableMinification(boolean value)

        Indicates whether output content (HTML, SVG and CSS) should be minified. Default value is false.

        Example:
        The following example demonstrates how to enable minification.

         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         String guid = "C:\storage\document.doc";
         HtmlOptions options = new HtmlOptions();
         options.setEnableMinification(true);
        
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - Whether output content (HTML, SVG and CSS) should be minified.
      • setEnableResponsiveRendering

        public void setEnableResponsiveRendering(boolean value)

        Indicates whether rendering will provide responsive web pages, that look well on different device types. Default value is false.

        Example:
        The following example demonstrates how to enable responsive rendering.

         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         String guid = "C:\storage\document.doc";
         HtmlOptions options = new HtmlOptions();
         options.setEnableResponsiveRendering(true);
        
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - Whether rendering will provide responsive web pages
      • setExcludeFonts

        public void setExcludeFonts(boolean value)

        Indicates whether to include fonts into HTML. Default value is false.

        Note:
        When fonts are included, depending on option, they will be embedded inline as base64-encoded fonts or added as separate resources.

        Example:
        The following example demonstrates how to prevent adding fonts into HTML.

         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         String guid = "C:\storage\document.doc";
         HtmlOptions options = new HtmlOptions();
         options.setExcludeFonts(true);
        
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - Whether to include fonts into HTML.
      • setExcludeFontsList

        public void setExcludeFontsList(List<String> value)

        The list of font names, that will be excluded from HTML.

        Note:
        The fonts that are added into HTML, improve stability of the output view, at the same time increase the size the rendering result. This option, lets you find compromise, between stability and output size. Include the font names that are popular and exist in most systems. Please note, this property is active only when ExcludeFonts property is set to false.

        Example:
        The following example demonstrates how to exclude specific fonts.

         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler();
        
         String guid = "C:\storage\document.pptx";
         HtmlOptions options = new HtmlOptions();
         options.getExcludeFontsList().add("Times New Roman");
         options.setExcludeFontsList().add("Courier New");
        
         List<PageHtml> pages = htmlHandler.GetPages(guid, options);
         

        Parameters:
        value - The list of font names
      • setHtmlResourcePrefix

        public void setHtmlResourcePrefix(String value)

        Specifies prefix for HTML resources.

        Note:
        Resource prefix may be useful when resources for document are obtained via some REST API method. Supported replacement patterns: {page-number}, {resource-name}.

        Example:
        The following example demonstrates how to specify resource prefix.

         HtmlOptions htmlOptions = new HtmlOptions();
         htmlOptions.setResourcesEmbedded(false);
         htmlOptions.setHtmlResourcePrefix("http://example.com/api/getResource?name=")
         

        Example:
        The following example demonstrates how to specify resource prefix with replacement patterns.

         HtmlOptions htmlOptions = new HtmlOptions();
         htmlOptions.setResourcesEmbedded(false);
         htmlOptions.setHtmlResourcePrefix("http://example.com/api/pages/{page-number}/resources/{resource-name}");
         

        Parameters:
        value - The HTML resource prefix.
      • setIgnorePrefixInResources

        public void setIgnorePrefixInResources(boolean value)

        Indicates whether to ignore resource prefix for nested resources. Nested resource is a resource that resides inside another resource.

        Note:
        Resource prefixes when set by option, not only apply to the references of HTML resources, but also apply to the references inside resources that themselves contain other resources (e.g. CSS that link to external fonts or SVG images that links to other resources). In order to prevent adding prefixes inside resource documents set this option true.

        Example:
        The following example demonstrates how to ignore prefix when processing resources. In this example specified prefix will be added only inside HTML content, and will not be applied to the links inside CSS or SVG documents that will be generated.

         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         String guid = "C:\storage\document.doc";
         HtmlOptions htmlOptions = new HtmlOptions();
         htmlOptions.setResourcesEmbedded(false);
         htmlOptions.setHtmlResourcePrefix("http://example.com/api/pages/{page-number}/resources/{resource-name}");
         htmlOptions.setIgnorePrefixInResources(true);
        
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        Parameters:
        value - Whether to ignore resource prefix for nested resources.