如何使用docx4j将docx导出为png? [英] How to export docx to png using docx4j?

查看:524
本文介绍了如何使用docx4j将docx导出为png?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docx4j 3.3.0,当我运行下面的代码时,我收到ClassNotFoundException.

I'm using docx4j 3.3.0 and when I run the code below I get a ClassNotFoundException.

OutputStream os = new FileOutputStream(file);
FOSettings settings = Docx4J.createFOSettings();
settings.setWmlPackage(wmlPackage);
settings.setApacheFopMime("images/png");
Docx4J.toFO(settings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);

java.lang.ClassNotFoundException: org.docx4j.convert.out.fo.FOExporterXslt from [Module "org.docx4j-compat:main" from local module loader @19a1b0af (finder: local module finder @4656be4e (roots: C:\newton\jboss\modules,C:\newton\jboss\modules\system\layers\base))]

我确定我缺少依赖项,但是我不知道是什么.

I'm sure I'm missing a dependency but I don't know what.

推荐答案

在docx4j 3.3.0中,通过FO导出已移至另一个项目:

In docx4j 3.3.0, export via FO moved to a separate project:

https://github.com/plutext/docx4j-export-FO

如果您使用的是docx4j zip发行版,则将jars添加到optional/export-fo

If you are using the docx4j zip distribution, add the jars in optional/export-fo

如果您正在使用Maven,请添加:

If you are using maven, add:

<groupId>org.docx4j</groupId>
<artifactId>docx4j-export-fo</artifactId>
<version>3.3.0</version>

这篇关于如何使用docx4j将docx导出为png?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆