未找到图像 - XSL-FO

mau*_*dff 4 xml xsl-fo

尽管我已经设置了图像的正确路径,但 XSL-Fo 无法检索我的图像。

<fo:external-graphic src="../graphics/bullet.png" content-height="0.5cm" />
Run Code Online (Sandbox Code Playgroud)

每次尝试通过 Windows 命令提示符处理文件时,我都会收到此错误。

org.apache.fop.events.LoggingEventListener processEvent
SEVERE: Image not found. URI: bullet.png. (See position 26:80)
org.apache.fop.events.LoggingEventListener processEvent                                                       
SEVERE: Image not found. URI: bullet.png. (No context info available)
org.apache.fop.events.LoggingEventListener processEvent                                                                                
Run Code Online (Sandbox Code Playgroud)

源路径是 APACHE 的 FOP 图像示例提供的确切格式。我什至在渲染外部图形时执行了他们的“image.fo”文件,但仍然遇到了上面的错误(使用不同的图像文件)。

有替代解决方案吗?

Ton*_*ham 6

相对 URI 相对于基本 URI ( https://xmlgraphics.apache.org/fop/fo.html#external-resources )。

如果您未在 FOP 配置中设置基本 URI,则基本 URI 是当前目录 ( https://xmlgraphics.apache.org/fop/1.1/configuration.html )。

图像文件相对于运行 FOP 的目录在哪里?


当您使用以下内容时它是否有效:

<fo:external-graphic src="examples/fo/graphics/bullet.png" content-height="0.5cm" />
Run Code Online (Sandbox Code Playgroud)

  • 然后首先尝试输入绝对路径:`file:///C:/.../examples/fo/graphics/bullet.png`,这样FOP就无法选择在哪里找到文件。其次,尝试使用“-x”或“-d”(https://xmlgraphics.apache.org/fop/trunk/running.html)运行,看看是否为您提供了足够的信息来了解 FOP 认为它从哪里运行。 (3认同)