2014-10-16 74 views
1

XSL-Fo無法檢索我的圖像,雖然我已經設置了正確的圖像路徑。Image not found-XSL-FO

<fo:external-graphic src="../graphics/bullet.png" content-height="0.5cm" /> 

我在每次嘗試通過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                     

源路徑是由APACHE的FOP圖像示例提供的確切格式。我甚至在渲染外部圖形時執行了它們的「image.fo」文件,並且仍然遇到了上面的錯誤(使用不同的圖像文件)。

是否有替代解決方案?

回答

3

相對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" /> 


是否當你使用它的工作?

+0

我的圖像文件的相對路徑:「examples \ fo \ graphics」。 – maudff 2014-10-16 13:06:52

+0

XML-FO仍然無法使用該路徑檢索圖像。 – maudff 2014-10-16 15:11:48

+0

然後首先嚐試放入絕對路徑:'file:/// C:/.../ examples/fo/graphics/bullet.png',這樣FOP沒有選擇在哪裏找到文件。其次,嘗試使用'-x'或'-d'(https://xmlgraphics.apache.org/fop/trunk/running.html)運行並查看是否給你足夠的信息來查看FOP認爲它運行的位置。 – 2014-10-16 15:23:29

1

我的外部圖形標記是這樣的:

<fo:external-graphic content-height="15.73mm" src="url('logo.png')"/> 

,我不得不把logo.png文件在同一目錄下的XSL文件。

也就是說,我的FOP命令是這樣的:

​​

,我不得不把.png文件中XMLFILES目錄。

我這樣做是因爲接受的答案是URI是「當前目錄」。