replaceVariablebyHTML
- addBackgroundImage
- addFooter
- addHeader
- addLineNumbering
- addPageBorders
- addProperties
- addSection
- createDocx
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importHeadersAndFooters
- importStyles
- modifyPageLayout
- removeFooters
- removeHeaders
- setBackgroundColor
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addTable
- addTableContents
- addText
- addTextBox
- addWordML
- embedHTML
- clearBlocks
- deleteTemplateBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- tickCheckbox
replaceVariablebyHTML
Replaces a single variable by HTML.
This method allows the insertion of HTML into a template. You may insert it as a "block", e.g. removing the corresponding paragraph and substituting it by the block of WordML, or "inline", e.g. just replacing the variable by inline WordML.
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.
var
The template variable to be replaced by the HTML content.
type
The substitution type, it can be:
- "block": the variable, together with its containing paragraph, is replaced by the HTML content.
- "inline": only the variable is replaced by the inline HTML content.
html
The HTML code to be translated into WordML: it can be a string or the path to a file.
options
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). |
target | String | Possible values are: document (default), header, footer, footnote, endnote, comment. This option sets the scope of the replacement procedure. |
wordStyles | HashMap<String, String> | Associate different Word styles to HTML classes, ids or tags. |