使用 Apache FOP 1.0 生成 TIFF - TIFFImageEncoder4
我已成功使用 Apache FOP 通过 Ant 任务生成 PDF。 我也有 Java 代码(使用 Axis2 的 Web 服务)成功地工作和生成 PDF,但一直在使用 Ant 任务,因为它可以更快地正确测试我的样式表。
现在我已经可以使用 PDF,我尝试满足我正在处理的项目的第二个要求 - 即生成 TIFF。相同的样式表、相同的源文档,但输出是 TIFF。
ANT 任务如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<project name="FOPAnt" default="generate-pdf-from-transform" basedir=".">
<property name="fop.home" value="D:\Dev\Java\libraries\fop-1.0-bin\fop-1.0"/>
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<fileset dir="${fop.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${fop.home}/build">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
当我运行这个时,我收到以下错误:
BUILD FAILED
D:\Dev\Java\FopConverter\workspace\FOPAnt\build.xml:30: java.lang.Error: TIFFImageEncoder4
我已经用谷歌搜索了这个错误,并且似乎需要在类路径中包含 JAI ImageIO 工具。
我发现的反复参考是这样的: https://issues.apache.org/bugzilla/show_bug.cgi?id=49681
我注意到 jai_imageio.jar 实际上已经在我的 ${fop.home}/build
文件夹中。 我是一个 Java 新手,所以如果我错了,请纠正我,但在我看来,JAR 已经包含在我上面的 ANT 脚本中的类路径中了?
我尝试使用网络服务 - 已将 jai_imageio.jar 添加到构建路径,并且它将进入 WEB-INF/lib
- 出现相同的错误。 已尝试按照该错误线程中的建议使用不同的颜色配置,但没有运气。
真的很挣扎。令人沮丧的是,PDF 生成效果很好。 这样做有点碰壁。
编辑:经过更多研究,我也许应该指出我正在使用 Windows 7 x64。我将重新安装 x86 JRE(将尝试 JRE 7)。
I have successfully been using Apache FOP to generate a PDF using an Ant task.
I also have Java code (Web Service using Axis2) successfully working and producing PDFs, but have been using the Ant Task as it's much faster to properly test my stylesheet.
Now that I have PDF working, I tried to meet the second requirement of the project I am working on - that is generating a TIFF. Same stylesheet, same source document, but output is a TIFF.
The ANT task looks like the below:
<?xml version="1.0" encoding="UTF-8"?>
<project name="FOPAnt" default="generate-pdf-from-transform" basedir=".">
<property name="fop.home" value="D:\Dev\Java\libraries\fop-1.0-bin\fop-1.0"/>
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<fileset dir="${fop.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${fop.home}/build">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
When I run this, I get the following error:
BUILD FAILED
D:\Dev\Java\FopConverter\workspace\FOPAnt\build.xml:30: java.lang.Error: TIFFImageEncoder4
I have googled and googled for this error, and it seems as though there is a requirement to include JAI ImageIO tools in the class path.
The recurring reference I found is this:
https://issues.apache.org/bugzilla/show_bug.cgi?id=49681
I noticed the jai_imageio.jar is actually already in my ${fop.home}/build
folder.
I'm a bit of a Java newbie, so correct me if I'm wrong, but looks to me like the JAR is included in the classpath already in my above ANT script?
I have tried using the webservice - have added the jai_imageio.jar to the build path and it is going into WEB-INF/lib
- getting the same error.
Have tried using different colour configurations as suggested in that Bug thread, but no luck.
Really struggling with this. It's frustrating, as the PDF generation worked well.
Hit a bit of a brick wall with this.
EDIT: After more research, I should maybe point out I'm using Windows 7 x64. I will re-install an x86 JRE (will try JRE 7).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保它是 ImageIO TOOLS 而不仅仅是 ImageIO;两个完全不同的东西。
以下是我在基于 FOP 的 TIFF 生成器中使用的库;我避免使用 XML 配置并直接使用我自己的自定义渲染器:
Make sure it is ImageIO TOOLS and not just ImageIO; two completely different things.
Here are the libraries I use in my FOP-based TIFF generator; I avoid the XML config and go straight with my own custom renderer:
我通过以下步骤完成了此工作:
在目标服务器上安装 JRE 1.4(Jai 图像 io 工具需要此
安装)。必须是 x86(32 位)。
a) j2re-1_4_2_19-windows-i586-p.exe 有效
安装 JRE7(同样,必须是 x86)
安装 Tomcat6 - 将 JRE7 设置为它是 JRE。
确保 JAVA_HOME 设置为 JRE7 根文件夹。
确保 %JAVA_HOME%\bin 在 PATH 变量中
安装 jai_imageio-1_1-lib-windows-i586-jre.exe。它应该安装到 JRE7 中。
我使用的是 x64,并且安装了 x64 JRE 和 JDK。这是我问题的根源。
这修复了它,所以我的网络服务可以在 TomCat 中运行。尚未尝试过 ANT 任务。 JAI ImageIO Tools 似乎依赖于 DLL,它只能在 32 位中运行。
我认为如果是 32 位,并且指向 32 位 JDK/JRE,这在 Eclipse 中将无法正常工作
I got this working by following these steps:
Install JRE 1.4 on target server (Jai image io tools needs this
to install). Has to be x86 (32bit).
a) j2re-1_4_2_19-windows-i586-p.exe works
Install JRE7 (again, has to be x86)
Install Tomcat6 - setting JRE7 as it's JRE.
Ensure JAVA_HOME is set as the root JRE7 folder.
Ensure %JAVA_HOME%\bin is in the PATH variable
Install jai_imageio-1_1-lib-windows-i586-jre.exe. It should install into JRE7.
I am on x64 and had x64 JRE and JDK installed. This this was the root of my problem.
This fixed it so my webservice works in TomCat. Haven't tried the ANT Task yet. JAI ImageIO Tools seems to have a dependency on DLLs, which work only in 32bit.
I assume this would not work fine in Eclipse if 32 bit, and pointing at 32bit JDK/JRE