Apache FOP 2.0 - 为什么找不到用于 SVG 的 ImagePreloader?

Apache FOP 2.0 - Why is no ImagePreloader found for SVG?

我在 jsf 应用程序(JBoss 7)中使用 Apache FOP 2.0 创建 pdf 文件。但是如果我想包含一个 svg,我会收到以下错误:

Image not available. URI: image/svg.svg. Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for image/svg.svg (No context info available): org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for image/svg.svg

该错误仅发生在 svg 文件中。其他图像类型(jpg 或 png)可以正常工作。所以我做了一些研究并找到了一些方法:


Apache FOP in a Java Applet - No ImagePreloader found for data

我更改了我的 pom,因此 xmlgraphics-commonsfop 之前加载,但它不起作用。我在 2.0.1 版中使用 xmlgraphics-commons batik 在 1.8 版中使用 avalon-framework(api 和 impl)在 4.3.1 版中。


http://apache-fop.1065347.n5.nabble.com/FOP-1-0-images-fail-to-render-td7348.html

我最后的方法是使用上次 post(来自 morjane)的提示,但它没有解决我的问题。


有些条码库有问题,但我没有使用。

如果有人能给我提示或知道如何解决这个错误,我将不胜感激。请询问是否需要更多信息。提前致谢。

xercesImpl 添加到我的 pom 解决了问题。

<dependency>
   <groupId>xerces</groupId>
   <artifactId>xercesImpl</artifactId>
   <version>2.11.0</version>
</dependency>

它还修复了我使用蜡染将 .svg 转换为 .eps 时出现的以下错误:

org.apache.batik.transcoder.TranscoderException: null Enclosed Exception: SAX2 driver class org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser not found.