How to display fixed image height and width using xsl-fo with apache fop 0.95

北城余情 提交于 2019-12-04 16:51:12

问题


I am trying to fix the height and width of image in pdf generated using fop 0.95. Here is the code used for it

<fo:external-graphic src="s\image.png" height="2.00in" width="2.00in"/>

Following also does not work

<fo:external-graphic src="s\image.png"  content-height="scale-to-fit" height="2.00in"  content-width="2.00in"/>

These gives us the image that is governed by width . In summary I am trying to stretch the image rather than keeping the aspect ratio using fop 0.95.Does any one have idea for it?


回答1:


These gives us the image that is governed by width . In summary I am trying to stretch the image rather than keeping the aspect ratio using fop 0.95.

By default fop keeps the aspect ratio regardless of the image height and width specified. This means fop does uniform scaling by default.

To have rather stretched image according to your specification, you should use non-uniform scaling. This way:

<fo:external-graphic src="s\image.png"  content-height="scale-to-fit" height="2.00in"  content-width="2.00in" scaling="non-uniform"/>

This will display your image.png image with height 2.00in and width 2.00in.

Hope this helps. Thank you,



来源:https://stackoverflow.com/questions/1957847/how-to-display-fixed-image-height-and-width-using-xsl-fo-with-apache-fop-0-95

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