Inserts HTML content into the Word document.

public void embedHTML(String html)
public void embedHTML(String html, OptionsHTML options)

This method allows the insertion of HTML into the current Word document.

This method transforms HTML directly into WordML and it is compatible with all DOCX readers.

You may find a more detailed explanation of this useful method in the HTML to Word section of the API documentation.



The HTML code to be translated into WordML: it could be a string or the path to a file.


The possible keys and values are:

Key Type Description
addDefaultStyles Boolean True as default, if false prevents adding default styles when strictWordStyles is false.
baseURL String The base URL used to complete the relative paths of links and images.
customListStyles Boolean If true checks if there is a custom list style with that name and uses it.
disableJavaScript Boolean True as default, if false enables JavaScript.
downloadImages Boolean If true inserts the images into the docx document, otherwise just links them as an external source.
filter String Only renders the filtered contents using a CSS selector.
isFile Boolean True for files and false for strings.
parseAnchors Boolean If true parses the anchors included in the HTML code.
parseDivs String paragraph. By default the method parses the div elements as containers.
parseFloats Boolean If true preserves the floating properties of images and tables.
strictWordStyles Boolean If true ignores all CSS styles and uses the styles set via the wordStyles option (see next).
wordStyles HashMap<String, String> Associate different Word styles to HTML classes, ids or tags.
Code samples

Example #1

The resulting Word document looks like: