How to display fixed image height and width using

2019-03-25 04:20发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-03-25 05:08

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,

查看更多
登录 后发表回答