Word embedding

Word support embedding documents transparently within the main document. This can be used for various purposes:

  • showing HTML/RTF in parts of the document
  • using master template with various subreports
  • conditionally adding parts of the document

Tags will be detected and process transparently, so no special code is required to process such setups.
Documents are embedded when appropriate type is detected:

Embedding HTML

On Github there is one example which shows different approaches to embedding HTML into Word.
To convert HTML to OOXML two options are possible:

  • Convert HTML to OOXML docx format via 3rd party library
  • Use Word to display embedded HTML

They both have their pros and cons. Primary con is that this relies heavily on Word. If you are using LibreOffice to display such HTML it will not work as expected.
But various generic HTML to OOXML converters are also unable to correctly convert HTML into OOXML for complex use cases.

In practice when Word template

Template document
Is bound with HTML such as:



  • Number 1
  • Number 2

some text in red!

Table with columns
Row with link to Templater
Even links via image  

The output will look like:

Resulting document

Dynamically specifying subreports

One way to have dynamic parts of the documents is to have one big documents with all possible options and then remove parts which are not relevant.
This is usually implemented by having either something like collapse plugin which removes section of the document or by having data structure and document set up in such a way that empty collections end up removing sections of the document.

While such setup is often simpler, sometimes it's much easier to have a location in the document where a subdocument will be injected during the processing.
Similarly to HTML example, but instead of HTML, we can use docx files to replace a tag.

Back to Features