Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 498
Thunder Avatar asked Dec 24 '09 10:12

Thunder


1 Answers

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,

like image 135
sangam Avatar answered Sep 18 '22 11:09

sangam