XSL-FO 外部图形未显示 [英] XSL-FO external-graphic not showing
本文介绍了XSL-FO 外部图形未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在将外部图形显示在我的 PDF 中时遇到了一些问题.我已经尝试使用 url()
使用各种路径,但似乎没有任何效果.是不是我还缺少其他东西?
I'm having some issues getting the external-graphic to show in my PDF. I've tried using all sorts of paths using the url()
but nothing seems to work. Is it something else I'm missing?
<fo:table-cell>
<fo:block>
<fo:external-graphic src="url(ss/naam.png)"></fo:external-graphic>
</fo:block>
</fo:table-cell>
推荐答案
我使用的是 Apache FOP 1.1 版本.
I am using Apache FOP 1.1 Ver.
首先,您应该告诉 apache FOP,以下方式的基本路径在哪里.您应该照原样复制代码.
first you should tell apache FOP that where is base path in follwing way. You should copy code as it is.
fopFactory = FopFactory.newInstance();
// for image base URL : images from Resource path of project
String serverPath = request.getSession().getServletContext().getRealPath("/");
fopFactory.setBaseURL(serverPath);
// for fonts base URL : .ttf from Resource path of project
fopFactory.getFontManager().setFontBaseURL(serverPath);
在您的 XSL 模板文件中
In your XSL template file
<fo:table-cell>
<fo:block>
<fo:external-graphic src="url(resources/naam.png)"></fo:external-graphic>
</fo:block>
</fo:table-cell>
这里的 naam.png 将在资源/目录中
我在项目的资源目录中添加了所有图像和所需的字体文件.它对我来说很好.谢谢
I added all images and required font font files in resource director of my project. It is working fine for me. Thank you
这篇关于XSL-FO 外部图形未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文