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

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

问题描述

我使用以下代码以 PDF 格式显示 PNG 图像.我使用 因为 不满足我显示图像的要求.请参阅问题 外部图形

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.

widthheightviewbox 属性添加到 svg 元素让 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天全站免登陆