【发布时间】:2014-07-01 13:45:31
【问题描述】:
我想在将由 FOP 生成的 PDF 上渲染图像。为了渲染图像,我使用标签<fo:external-graphic> 如下:
<fo:external-graphic src="url('../offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8')" inline-progression-dimension.maximum="100%" content-height="scale-down-to-fit" content-width="scale-down-to-fit"> </fo:external-graphic>
我还尝试将完整的 URL 设为:
<fo:external-graphic src="http://10.2.10.79/Web/offlinePaper/displayImage?disImg=e391d672-ebf4-44d8-86cb-2cf987a50bf7" inline-progression-dimension.maximum="100%" content-height="scale-down-to-fit" content-width="scale-down-to-fit"> </fo:external-graphic>
在控制器中,我有一个请求映射(../offlinePaper/displayImage),它从getParameter 获取图像名称disImg,然后解密图像并返回OutputStream。
但是当我生成 PDF 时,我发现日志文件中的错误为:
Image not available. URI: http://10.2.10.79:80/Web/offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8. Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for http://10.2.10.79:80/Web/offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8 (No context info available)
但是,如果我复制此 URL 并粘贴到 URL 中,则图像会显示在浏览器中,并且我还发现,当我生成 PDF 时,假定会调用图像解密的请求映射不会被调用。
更新
还有一个奇怪的想法,我知道如果 Web 服务器是 Tomcat,则使用相同的代码成功生成 PDF,但如果我在 Glassfish 上部署应用程序,则会出错。
【问题讨论】:
-
我只有jsp生成的图像有类似的问题,我也使用Outputstream。您是只更改了 Web 服务器还是在代码中进行了其他更改?这是我的问题stackoverflow.com/questions/24768480/image-not-displayed-on-pdf
-
@FernandoPrieto,不,我刚刚更改了服务器。目前我通过写
URIResolver解决了这个问题。
标签: java xsl-fo apache-fop