Report Word template - Format injected HTML as defined in the docx template


I have a question regarding the reporting addon.

What I would like to achieve is that I define a word template with styling the corresponding Header 1, Header 2 etc. via the regular Word styling options.

Then I want to inject dynamical content in the template. But it is not just a regular text replacement. Instead, what I would want to achieve is to have a text inside some entity that is formatted either as HTML or as Markdown.

I use the ${html} format for the value. It correctly spits out the rendered HTML in the resulting word document. But what I would like to have is that when I inject a HTML H1 tag, then it should be translated into the corresponding header of Word, so that it inherits its formatting.

This way I would be able to inject highly dynamic content into the word document.

Is this possible to do in Yarg out-of-the-box?

Attached you find an example of the template file as well as the resulting word document:

visit-documentation-report-template.docx (41.8 KB)

visit-documentation-example-with-not-correctly-formatted-html.docx (191.2 KB)

I cannot simply format the replacement string ${VisitDocumentation1.diagnose} - because then it would format everything within this string exactly like that, right?

Here is an example of where it is directly done via docx4j:


Ok, looking a little bit more to it I realized that it seems that Yarg already tries to do basically this replacement. If I understand correctly, yarg already uses the part for docx4j that is capable of doing exactly this:

Is that correct?

In fact the logs print out that it tries to convert it, but there is a message:

09:18:16.029 WARN    - Couldn't find/read; not found via classloader.
09:18:16.085 WARN    - Falling back to solid
09:18:16.085 WARN  o.d.convert.out.html.HtmlCssHelper      - ! null rPr for character style Absatz-Standardschriftart

I’m just curious what you did in the end, as the topic is also interesting to me?