On 03 Dec 2008, at 12:28, sandraB wrote:

Hi

I'm using fop-0.95 to generate a PDF file from an xml template, I have a problem regarding the external-graphic renderer. I never had the correct size in the pdf for gif or png images even if I can modifiy the size by changing the external-graphic attributes. Could you help me to resolve this
issue.

To get the most accurate results:


The xml
<!-- The same image (size gived by Gimp) -->
img src="images/topic.png" content-width="136mm" content- height="88mm" /> img src="images/topic.gif" content-width="13mm" content- height="8mm" /> img src="images/topic.gif" content-width="13.652cm" content- height="8.855cm"

Sizes in mm/cm as displayed by image viewers are not always dependable. If there is no native resolution present in the image file, most viewers default to 96dpi or 120dpi for on-screen display. FOP, when using the PDF output target, would on the other hand assume a resolution of 72dpi, which would make the same image appear larger than an image viewer shows it to be.

What you should look for is the size in pixels /and/ the proper resolution (if any).

Once you have those, the calculations become rather straightforward.
For example:
default content-width = (intrinsic width in pixels) * (native resolution / 72)

If you want to avoid doing any calculations altogether, then use height/width to specify the desired size, and 'scale-to-fit' for content-width/content-height. No matter what the intrinsic size is, FOP will then do its best to scale the image to fit the specified height/width.

Example:

<fo:external-graphic
  height="2cm" width="2cm"
  content-height="scale-to-fit" content-width="scale-to-fit"
  src="..." />

The resulting image will never take up more/less space than 2x2cm. Starting with FOP 0.95, support was added for 'scale-down-to-fit' if you want to keep small images in their intrinsic size.


HTH!

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to