Replace text with HTML code in dotx files using docx4j in java

519 Views Asked by At

I have some document templates(.dotx files) with placeholders. I need to read that template and replace placeholders with actual text which is coming from database columns. I am able to do this using docx4j's WordprocessingMLPackage, but problem is, in some of database columns there is HTML code. This is text coming from a rich text editor fields. When I tried to replace this text in word document template, I am getting pure html code is copied into document. I want convert that html code into actual html text and write into document. How am I able to achieve this?

1

There are 1 best solutions below

0
On

You can use https://github.com/plutext/docx4j-ImportXHTML either directly, or via content control databinding OpenDoPE extensions.