fo:instream-foreign-object无法正确显示图像 [英] fo:instream-foreign-object does not show the image properly

查看:195
本文介绍了fo:instream-foreign-object无法正确显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在PDF中显示PNG图片.我使用<fo:instream-foreign-object>是因为<fo:external-graphic>无法满足我显示图像的要求.请参阅问题外部图形

I use the below code to show a PNG image in PDF. I use <fo:instream-foreign-object> because <fo:external-graphic> does not fulfil my requirement to show a image. Refer to issue external graphic

<fo:instream-foreign-object width="50%" content-width="scale-to-fit">
   <svg> 
       <image height="439px" width="1037px" xlink:href="test.png"/>
   </svg>
</fo:instream-foreign-object>

通过上述使用,我无法在文档中得到图片.图像未正确放置在页面中,下一段中的文本覆盖在页面顶部. 请提出实现方法的建议.

With the above use, I am not able to get the picture in the document. The image is not properly placed in the page and the text in the next paragraph is overlay on top of it. Please suggest how to achieve it.

推荐答案

使用您显示的内容,AH Formatter将把整个页面用于包含图像的fo:block并将下一个段落放在下一页.

With what you show, AH Formatter will use the whole page for the fo:block containing the image and put the next paragraph on the next page.

svg元素中添加widthheightviewbox属性,至少可以使AH Formatter正确调整图像大小:

Adding width, height, and viewbox attributes to the svg element lets AH Formatter, at least, size the image properly:

<fo:instream-foreign-object width="50%" content-width="scale-to-fit">
    <svg xmlns="http://www.w3.org/2000/svg" width="1037" height="439"
        viewBox="0 0 1037 439">
        <image height="439px" width="1037px" xlink:href="test.png"
            xmlns:xlink="http://www.w3.org/1999/xlink" />
    </svg>
</fo:instream-foreign-object>

让FOP为图像使用正确的高度可能就足够了.

It may be enough to let FOP use the correct height for the image.

这篇关于fo:instream-foreign-object无法正确显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆