I shall start with answer given by @JasonPlutext on one of the similar questions at docx4j forum. I have to mention that I was using jars which had this issue. Then, I followed below link:
https://www.docx4java.org/forums/docx-java-f6/convert-html-to-docx-with-rtl-for-hebrew-arabic-language-t2712.html
and found the jars from the below comments on the above linked page:
You can try https://docx4java.org/docx4j/docx4j-Imp … 180801.jar
It contains https://github.com/plutext/docx4j-Impor … f378022303
Could you please take a look at https://github.com/plutext/docx4j-Impor … iTest.java and add additional tests for mixed Hebrew/Arabic and left to right text, especially for any cases where you feel the implementation is not correct.
Also, the jars were not downloading, so I searched the name of jars and downloaded them with all the dependencies from jardownload.com. Though the commons-codec and commons-io jars were 1.3, which need to be upgraded to latest jars for image getting displayed in docx format after conversion. But, make sure that the html is well formed since docx4j requires strict adherence to well formed html.