public static void editorToWork(File file, String html) throws Exception {
html = html.replaceAll("<p(.*)>", "<p $1 style=\"\"> ");
html = html.replaceAll("<p(.+style.+)style.+>", "<p $1>");
html = html.replaceAll("<p(.+)style=\"(.*)\"(.*)>", "<p $1 style=\" $2 margin-top:0px; margin-bottom:0.1;\" $3>");
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
String h = "<html><head><title></title></head><body>"+html+"</body></html>";
wordMLPackage.getMainDocumentPart().addAltChunk(AltChunkType.Html, h.getBytes());
wordMLPackage.save(file);
}
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.6</version>
</dependency>