fo:instream-foreign-object does not show the image properly

扶醉桌前 提交于 2019-12-23 05:07:43

问题


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.


回答1:


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.

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>

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



来源:https://stackoverflow.com/questions/37654452/foinstream-foreign-object-does-not-show-the-image-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!