Hi, Etienne!
Recently I have faced this problem, as well.
To solve this, I wrote an extension class ImageInfo,
that provides the following functions:
public int height(String anImageUrl);
public int width(String anImageUrl);
The implementation of these functions use the classes/interfaces
org.apache.fop.image.analyser.ImageReader
org.apache.fop.image.analyser.ImageReaderFactory
which are supplied with the fop.jar.
For instance height() is implemented as follows:
public int height(String anImageUrl)
{
try {
URL u = new URL(anImageUrl);
InputStream in = u.openStream();
ImageReader ir = ImageReaderFactory.Make("", in);
return ir.getHeight();
}
catch (Exception ex) {
return -1;
}
}
With these extension-functions a stylesheet could
determine, whether to scale the image or not:
<xsl:stylesheet ...
xmlns:img="my.extensions.ImageInfo"
extension-element-prefixes="img">
...
<fo:external-graphic>
<xsl:attribute name="src">http://www.foo.bar/image.gif</xsl:attribute>
<xsl:if test="img:height('http://www.foo.bar/image.gif') > 200">
<xsl:attribute name="height">200pt</xsl:attribute>
</xsl:if>
<xsl:if test="img:width('http://www.foo.bar/image.gif') > 200">
<xsl:attribute name="width">200pt</xsl:attribute>
</xsl:if>
</fo:external-graphic>
...
I hope this helps!
Harald
--
Harald Hett <[EMAIL PROTECTED]>
Gesellschaft für integrierte Systemplanung
"Etienne Baert (SPSInfoquest nv)" wrote:
>
> Dear fop-ers,
>
> I have to include a generated picture into a pdf document.
> I am thus using <fo:external-graphic .../>.
>
> However, as my image is the result of a servlet process sent
> as jpeg, I do not know in advance the image size. Once the
> size of the image fits the available size, I do not have any
> problem ... but in other cases, my image is not embedded
> and extra blank pages are added to the final document.
>
> How can I have my picture taking place into the available
> space ?
>
> Many thanks,
> Etienne Baert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]