RE: [xep-support] scale-when-image-is-too-big

Date: Tue Oct 15 2002 - 01:31:58 PDT

> Do you have example code for passing the new image height & width values
> the XSL template? Are you using xsl:param & with-param coupled with
> xsl:call-template?

Yes, this is what I use. Here's some code:

My xml data file has this format:

<?xml version="1.0" encoding="UTF-8"?>

When I handle graphics, I call the template setScaling...

<fo:external-graphic alignment-baseline="middle">
  <xsl:attribute name="src"><xsl:value-of select="$filename"
  <xsl:call-template name="setScaling">
    <xsl:with-param name="filename" select="$filename" />

...which looks like this:

<xsl:template name="setScaling">
  <xsl:param name="filename" />
  <xsl:variable name="imageWidth">
select="document($dataFile)//*[name()=$filename]/*[name()='width']" />
  <xsl:variable name="imageHeight">
select="document($dataFile)//*[name()=$filename]/*[name()='height']" />
  <xsl:variable name="xScale">
      <xsl:when test="number($imageWidth) > number($typeAreaWidth)">
        <xsl:value-of select="100 * number($typeAreaWidth) div
number($imageWidth)" />
        <xsl:value-of select="100" />
  <xsl:variable name="yScale">
      <xsl:when test="number($imageHeight) > number($typeAreaHeight)">
        <xsl:value-of select="100 * number($typeAreaHeight) div
number($imageHeight)" />
        <xsl:value-of select="100" />
  <xsl:variable name="scale">
      <xsl:when test="number($yScale) > number($xScale)">
        <xsl:value-of select="$xScale" />
        <xsl:value-of select="$yScale" />
  <xsl:attribute name="content-width"><xsl:value-of select="$scale"
  <xsl:attribute name="content-height"><xsl:value-of select="$scale"

(Actually this is a simplified version because I support pictures inside
tables as well).

> However, I would like to attract your and other users' attention to the
> that acrobat (or any other pdf/ps interpreter) is usually a poor quality
> performer when it comes to scaling raster images.

For our needs, the image quality is sufficient.


Matthias Belz <>
Electronic Technologies, Springer-Verlag Heidelberg
By using the Service, you expressly agree to these Terms of Service

This archive was generated by hypermail 2.1.5 : Wed Dec 18 2002 - 08:41:28 PST