使用docx4j v3进行docx到html的转换

时间:2015-07-21 18:37:37

标签: java html docx4j

我正在尝试使用docx4j V3将docx转换为html。我是我的代码。

    File initialFile = new File("input/table_1.docx");
    InputStream is = new FileInputStream(initialFile);
    WordprocessingMLPackage wordMLPackage = Docx4J.load(is);
    HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
    htmlSettings.setWmlPackage(wordMLPackage);
    OutputStream out = new FileOutputStream("input/table_1.html");
    Docx4J.toHTML(htmlSettings, out, Docx4J.FLAG_EXPORT_PREFER_XSL);
    String result = ((ByteArrayOutputStream)out).toString();
    System.out.println(result);

这是我得到的错误。我用mvn来解决jar dependency.can任何人都有帮助 错误:

  

线程“main”中的异常   org.docx4j.openpackaging.exceptions.Docx4JException:无法加载xml   来自溪流   org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:504)     在   org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:302)     在   org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:170)     在org.docx4j.Docx4J.load(Docx4J.java:195)

0 个答案:

没有答案