java - org.apache.xmlgraphics.image.loader.ImageException : The file format is not supported. 未找到 ImagePreloader

标签 java xslt apache-fop

我正在使用 Apache FOP 1.1(Java) 生成 PDF 文件。 它在 Windows 机器上工作正常,但是当我使用 Ubuntu 机器时,我收到此错误

org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported.  No ImagePreloader found

我有点困惑。请给我解决方案来解决这个问题。 谢谢

最佳答案

问题是 fop jar 文件和 xmlgraphics-commons jar 中 META-INF/services/ 中存在的配置文件之间存在冲突文件。

如果您使用maven并希望避免有时可能会造成麻烦的排除,您可以使用ma​​ven shade插件构建jar并强制连接META中的配置文件-INF/服务/。像这样的片段对我有用:

   <build>
        <finalName>desired_jar_name</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <transformers>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>my.main.class</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

关于java - org.apache.xmlgraphics.image.loader.ImageException : The file format is not supported. 未找到 ImagePreloader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27401158/

相关文章:

java - 如何从 Dual Sim Android 设备获取 Sim 运营商名称?

html - 在 Mac 上将 plist xml 文件转换为 html/pdf 格式

java - Apache FOP 中的印度字体支持

java - Spark Java scala 错误

java - 删除附加的字符串到 StringBuilder

xml - 替代 Altova 的 MissionKit

c# - 使用 caml 和 xslt 的 Sharepoint webpart

java - Apache FOP,将图像缩小到以毫米为单位的精确尺寸

xml - "Content is not allowed in prolog"错误但在 XML 声明之前什么也没有

java - Android 中如何获取 String[] 的项目