Starting in 9.1, WordTemplate has the ability to embed well-formed HTML snippets into DOCX files.
Template
The merge field that corresponds to the HTML snippet data must use the HTMLSnippet
modifier.
For more information on merge field modifiers, please see Creating Merge Fields.
Data
The HTMLSnippet modifier takes a string of well-formed HTML. An exception will be thrown if:
- The HTML is not well formed. For example, the snippet is missing a corresponding closing tag.
- A data type other than
string
is passed to the merge field.
Remarks
The current version of the HTMLSnippet modifier does not convert the HTML into true Word formatting. It embeds an HTML document that contains the HTML snippet. This means that some applications may not be able to render the document completely. For example, when viewing a document with the Outlook document preview, the HTML may not be rendered correctly.
Documents that are merged using the Document(docx) modifier can contain HTML segments that are inserted using the HTMLSnippet modifier. However, if the document is very large or contains many layers of nested DOCX, HTML, RTF files or HTML snippets, Word may experience performance issues when rendering the combined document.