开源Docx4J 将docx文档转换成html文档
使用maven导入docx4j包
org.docx4j
docx4j
3.0.1
简单的测试访求
public static void docxToHtml(String filepath, String outpath) throws Docx4JException, FileNotFoundException{
WordprocessingMLPackage wmp = WordprocessingMLPackage.load(new File(filepath));
Docx4J.toHTML(wmp, "html/resources", "resources", new FileOutputStream(new File(outpath)));
}
public static void main(String[] args) throws Exception{
DocToHtml.docxToHtml("test.docx", "html/test.html");
}
这样就可以将docx文档转换成html文档,但是因为 文件格式的问题,不能转换doc文档