不好用,转完问题挺多,还找不到资料头疼。
public static void docxToHtml(String fileUrl) throws Exception {
    String path = fileUrl.substring(0,fileUrl.indexOf("."));
    File file = new File(fileUrl);
    WordprocessingMLPackage wordMLPackage = Docx4J.load(file);
    HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
    String imageFilePath =  path+"/images/";
    if(!new File(imageFilePath).exists())
        new File(imageFilePath).mkdirs();
    htmlSettings.setImageDirPath(imageFilePath);
    htmlSettings.setImageTargetUri("images"); 
    htmlSettings.setWmlPackage(wordMLPackage);
    String userCSS = "html, body, div, span, h1, h2, h3, h4, h5, h6, p, a, img,  ol, ul, li, table, caption, tbody, tfoot, thead, tr, th, td " +
            "{ margin: 0; padding: 0; border: 0;}" +
            "body {line-height: 1; padding: 30px;} ";
    userCSS = "body {padding: 30px;}";
    htmlSettings.setUserCSS(userCSS); //
    OutputStream os = new FileOutputStream(path+"/"+file.getName().substring(0,file.getName().indexOf("."))+".html");
    Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
    Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
}
public static void main(String[] args) throws Exception {
    WordToHtml.docxToHtml("E:\\desktop\\3.docx");
}