Ureadable content in DOCX report

After update of an existing DOCX-template, the output file (DOCX) containts some unreadable characters according Word.
word_error

In jmix 1.5 and 1.6

Create new report using wizzard (DOCX-template).
Run report → output file is OK.

Download DOCX-template, change something (layout, text, …), save and upload template.
Run report → when opening output file Word error shows.

Hello,

Was the original template made with a different version of MS Word, or was the new template made with a different format, like DOC instead of DOCX?

Kind regards,
Mladen

Hi Mladen,
The first template is created by the jmix wizzard and it works.

I use MAC to download the template and to open in Mac-Word. This is working fine.
Changed template upload to te report.
Run report works ok, result is a new reportname.docx file.

When opening the reportname.docx file in Mac-Word I get this error.

If you like, you can make a small test project on github, with the original template that works, and share it.
I will then change something in the template using PC. I feel that there may be a problem with MAC version of Word.

testdocxreport.zip (127.1 KB)

the default and changed template are included in the etc-subfolder

I was able to open your project and run it.
I have the same result as you - as soon as the original template is changed, saved, and imported to the report, it shows an error when opening.
I’m using Office 365, so it’s not Mac version.

Do you need to use Jmix 1.6? If not, I would try with the latest version for the new project, maybe it has a new ms word renderer version that would work.
Also, I would use Jasper template type, it’s a more complex but also more powerful, I’m able to get various output formats from it, like word, pdf, HTML …

If yes, then a Jmix team member is the best address to solve this.

Join the Jmix Slack channel
Slack

Hi Mile,

Problem was reproduced on version 1.7-RC. Ticket was issued: Unreadable content in DOCX report · Issue #4445 · jmix-framework/jmix
Thank you!

Regards,
Igor

After investigating the problem, it turns out that Microsoft introduced a new namespace prefix - w16sdtfl. The current version of Docx4j does not support this namespace, which causes edited templates to produce corrupted report files.

The fix for Jmix 2.x includes an updated version of Docx4j. However, for Jmix 1.x, we cannot upgrade to the latest version because Docx4j uses Jakarta namespaces in its code, which in some cases are incompatible with other dependencies. For full details, you can refer to this issue and the comment with explanation: JAXB-API has not been found on module path or classpath · Issue #4473 · jmix-framework/jmix · GitHub

The only workaround currently is to use another available applications to edit *.docx files, e.g. LibreOffice.