我想在 PDF 上渲染图像,该图像将由 FOP 生成。为了渲染图像,我使用标签<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)
它采用图像名称disImg
from getParameter
并解密图像并返回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 时,应该调用图像解密的请求映射不会被调用。
Update
还有一个奇怪的想法,我开始知道,如果网络服务器是,使用相同的代码 PDF 会成功生成Tomcat
但如果我将应用程序部署在Glassfish
它给出了错误。
在异常跟踪中:
ImageException:不支持该文件格式
FO 似乎能够找到一个ImagePreloader
根据文件扩展名。如果找不到任何东西,它就会崩溃。
我建议更改 url 的构建方式。应该包含真实的图像文件名。
所以,而不是:
../offlinePaper/displayImage?disImg=4bec89f0-5b97-40c3-b7c9-ac555a664df8
try
../offlinePaper/displayImage/disImg4bec89f0-5b97-40c3-b7c9-ac555a664df8.jpg
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)