使用Docx4j生成PDF时出现NullPointerException

时间:2017-09-27 16:22:57

标签: java pdf

这是我的应用抛出的错误:

Caused by: java.lang.NullPointerException
    at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:199)
    at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:159)
    at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:168)
    at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)
    at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)
    ... 63 more

代码:

InputStream is = ByteSource.wrap(bytes).openStream();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
Docx4J.toFO(foSettings, baos, Docx4J.FLAG_EXPORT_PREFER_XSL);

抛出NPE的行是

Docx4J.toFO(foSettings, baos, Docx4J.FLAG_EXPORT_PREFER_XSL);

这里可能有什么问题?

0 个答案:

没有答案