opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.19k stars 369 forks source link

xDocreport/ Freemarker cannot add html styling inside list #585

Open bonobothehappyape opened 1 year ago

bonobothehappyape commented 1 year ago

Hello,

i am using xdocreport to generate a questionnaire in docx with freemarker as template engine. version 2.0.4

when i iterate the list of questions, sometimes the text of the question contains html (from the backend). «[#list rootQuestions as q]»«${q.text}»«[/#list]» when i do metadata.addFieldAsTextStyling("q.text", SyntaxKind.Html);

i get an error that q is null, (neither q nor q.text is null from the backend)

freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> q  [in template "fr.opensagres.xdocreport.document.docx.DocxReport@7b6cee63!word/document.xml"
 at line 4, column 423]
FTL stack trace ("~" means nesting-related):
    - Failed at: #assign ___NoEscape0 = ___TextStyling... 
    -  [in template "fr.opensagres.xdocreport.document.docx.DocxReport@77750214!word/document.xml"
    -  at line 4, column 368]

but when i remove the field as text styling, i can see the string in the html format.

i have also tried to add the field as a list metadata.addFieldAsList("q.text");

is there a way to render html styling for a field inside a list ?