HTML Extended

Information and examples

Introduction

Thanks to the HTML Extended functionality, it is possible to invoke xmldocx tags and options not available through standard HTML tags. Thus, you can add contents such as headers, footers, comments, table of contents, cross-references and many other contents types, insert new sections, access properties not available in CSS and even add WordFragments.

This feature, available for Premium licenses, integrates with the embedHTML and replaceVariableByHTML methods with a set of custom tags that can be combined even with other HTML and CSS contents.

Supported contents

This is the complete list of supported contents and their default tags:

  • addBookmark: phpdocx_bookmark
  • addBreak: phpdocx_break
  • addComment: phpdocx_comment
  • addCrossReference: phpdocx_crossreference
  • addDateAndHour: phpdocx_dateandhour
  • addEndnote: phpdocx_endnote
  • addFooter: phpdocx_footer
  • addFootnote: phpdocx_footnote
  • addFormElement: phpdocx_formelement
  • addHeader: phpdocx_header
  • addHeading: phpdocx_heading
  • addImage: phpdocx_image
  • addLink: phpdocx_link
  • addMathEquation: phpdocx_mathequation
  • addMergeField: phpdocx_mergefield
  • addPageNumber: phpdocx_pagenumber
  • addSection: phpdocx_section
  • addShape: phpdocx_shape
  • addSimpleField: phpdocx_simplefield
  • addStructuredDocumentTag: phpdocx_structureddocumenttag
  • addTableContents: phpdocx_tablecontents
  • addText: phpdocx_text
  • addTextBox: phpdocx_textbox
  • addWordFragment: phpdocx_wordfragment
  • addWordML: phpdocx_wordml

Tag types

Tags are divided in two types: inline and block.

The inline ones do not admit children elements. They are the following:

  • phpdocx_bookmark
  • phpdocx_break
  • phpdocx_crossreference
  • phpdocx_dateandhour
  • phpdocx_formelement
  • phpdocx_heading
  • phpdocx_image
  • phpdocx_link
  • phpdocx_mathequation
  • phpdocx_mergefield
  • phpdocx_pagenumber
  • phpdocx_section
  • phpdocx_shape
  • phpdocx_simplefield
  • phpdocx_structureddocumenttag
  • phpdocx_tablecontents
  • phpdocx_text
  • phpdocx_textbox
  • phpdocx_wordfragment
  • phpdocx_wordml

The block ones allow children, either of the HTML or the HTML Extended tags. They are the following:

  • phpdocx_comment
  • phpdocx_endnote
  • phpdocx_footer
  • phpdocx_footnote
  • phpdocx_header

Options for each method are added with custom data attributes. You just need to write the option name after the prefix data-. E.g.: data-bold="true", data-type="start" o data-type="default".

Examples

HTML Extended is as easy to use as standard HTML tags. It is just necessary to enable the useHTMLExtended option to start working with the custom tags.

Adding contents using custom tags and HTML:

config.xml

content.xml

settings.xml

Add a TOC based on headings created with HTML and xmldocx tags:

config.xml

content.xml

settings.xml

Headers and footers:

config.xml

content.xml

settings.xml

Comments, endnotes and footnotes:

config.xml

content.xml

settings.xml

As shown in this last example, comments, endnotes and footnotes require a specific structure in order to correctly add all their content.