XML API - pdx:replaceVariablebyHTML

pdx:replaceVariablebyHTML

Replaces a single variable by HTML.

Note

You are reading the XML API documentation. For the PHP API method please go to replaceVariablebyHTML.

Description

Element definition

This element 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.

Practically all HTML tags and CSS styles are supported.

This element transforms HTML directly into WordML and it is compatible with OpenOffice and PDF conversion.

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

Attributes and sub-elements

variableName

The template variable name to be replaced by the HTML content.

replaceType

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.

data

The HTML code to be translated into WordML

options

Key Description
isFile True for files and false for strings.
addDefaultStyles True as default, if false prevents adding default styles when strictWordStyles is false.
baseURL The base URL used to complete the relative paths of links and images.
cssEntityDecode If true uses html_entity_decode to parse CSS, useful when using font families with non-ASCII names.
customListStyles If true checks if there is a custom list style with that name and uses it.
downloadImages If true inserts the images into the DOCX document, otherwise just links them as an external source.
filter Could be an string denoting the id, class or tag to be filtered or an array with a list of filters, if you want only a class introduce .classname, #idName for an id or for a particular tag, if you use the plain name it will search in ids, classes and tags.
parseAnchors If true parses the anchors included in the HTML code.
parseDivsAsPs If true parses the div elements as paragraphs.
parseFloats If true preserves the floating properties of images and tables.
removeLineBreaks If true removes extra line breaks that can be generated when transforming HTML that includes strings without a parent tag.
strictWordStyles If true ignores all CSS styles and uses the styles set via the wordStyles option (see next).
stylesReplacementType usePlaceholderStyles (keep placeholder styles). Applies to the following styles: pPr, rPr. Styles from the imported HTML are ignored. Empty as default. Only available in Premium licenses.
wordStyles One may associate different Word styles to HTML classes, ids or tags.
Code samples

Example #1

config.xml

content.xml

settings.xml

PHP code

The resulting Word document looks like: