当前位置: 首页 > 工具软件 > xhtmlrenderer > 使用案例 >

java docx4j导出HTML为word(.docx)报错:org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parse

漆雕原
2023-12-01
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): org.apache.xerces.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): org.apache.xerces.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): org.apache.xerces.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): org.apache.xerces.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): org.apache.xerces.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): org.apache.xerces.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: White spaces are required between publicId and systemId.
org.docx4j.org.xhtmlrenderer.exception WARNING:: Unhandled exception. Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 63; White spaces are required between publicId and systemId.

小白刚刚学习用docx4j,不明白报错说的SAX使用XmlReader(分析器)和无法加载XML资源(使用Trax变压器)


publicId and systemId又是什么?说需要空间?求大家帮忙解决一下


用的别人的代码,下面是部分代码
protected WordprocessingMLPackage xhtml2word(Document doc) throws Exception {

        WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.valueOf("A4"), true); //A4纸,//横版:true

        //configSimSunFont(wordMLPackage); //配置中文字体

        XHTMLImporterImpl xhtmlImporter = new XHTMLImporterImpl(wordMLPackage);

        wordMLPackage.getMainDocumentPart().getContent().addAll(//导入 xhtml

		xhtmlImporter.convert(doc.html(), doc.baseUri())); //调试到这里报错,查看XHTMLImporterImpl  API没发现有什么缺少的包


        return wordMLPackage;
    }


 类似资料: