Subject: Re: [xsl] Trouble adding an image to FO From: Tim Meals <tim@xxxxxxxxxxxx> Date: Tue, 25 May 2004 10:44:38 -0700 |
<xsl:param name="image-location" select="file:///C|/Temp/Report"/> [ ... other content goes here ... ] <fo:external-graphic src="{$image-location}/12345.gif"/>
Tim -- Tim Meals Applications Development Consultant tim@xxxxxxxxxxxx
I am using FOP to generate a PDF. The FO xml is coming from XSLT. The trouble is I cannot seem to get images to show up correctly. When I prototyped this from the command line and the xsl, FO and images were all in the same directory everything was cool but now that I have moved to code the images cannot be found by FOP.
Origonally I was producing an FO element like this:
<fo:external-graphic height="10pt" width="10pt"
src="15272099.gif" />
which yielded an error from FOP: [ERROR] Error while creating area : Error with image URL: 15272099.gif (The handle is invalid. ) and no base URL is specified
The images, FO and output PDF are still in the same
directory but it is not the current directory from the
command line any more the rendering is being done in
Java code. So I did some experimenting and tried
passing full paths like this:
<fo:external-graphic height="10pt" width="10pt"
src="C:\Temp\Report/8390677.gif" />
which yielded an error from FOP: [ERROR] Error in XObject : Error while loading image file:C:/Temp/Report/8390677.gif : class java.lang.ClassCastException - java/io/BufferedInputStream incompatible with java/awt/image/ImageProducer
I also tried file: URL formats which did not help. Then after doing some digging I found reference to an
FO function 'url()'. I tried that with XSL like this:
<xsl:variable name="iconFullPath">
<xsl:value-of select="concat('url("',
$outputDir, $fileSep, @publish:icon, '")')"/>
</xsl:variable>
<xsl:message>
<xsl:value-of select="$newLine"/>
<xsl:text>Adding a graphic to the FO XML. The icon
attribute is '</xsl:text>
<xsl:value-of select="@publish:icon"/>
<xsl:text>' and the full uri is '</xsl:text>
<xsl:value-of select="$iconFullPath"/>
<xsl:text>'.</xsl:text>
</xsl:message>
<fo:block font-size="12pt" line-height="15pt" start-indent="0.5cm"> <fo:external-graphic width="10pt" height="10pt"> <xsl:attribute name="src"><xsl:value-of select="$iconFullPath"/></xsl:attribute> </fo:external-graphic> <xsl:value-of select="@publish:qualifiedname"/> </fo:block>
Which creates these FO elements:
<fo:block start-indent="0.5cm" line-height="15pt"
font-size="12pt">
<fo:external-graphic height="10pt" width="10pt"
src="url("C:\Temp\Report/8390677.gif")" /> an.element.qualifed.name </fo:block>
Which produced xsl:message entry: Adding a graphic to the FO XML. The icon attribute is '8390677.gif' and the full uri is 'url("C:\Temp\Report/8390677.gif")'.; SystemID:<snip>
And this error from FOP [ERROR] Error in XObject : Error while loading image
file:C:/Temp/Report/8390677.gif : class
java.lang.ClassCastException -
java/io/BufferedInputStream incompatible with
java/awt/image/ImageProducer
Further digging around the internet yielded no other ideas. Any help, inspiration would be appreciated.
Thanks,
IL
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Trouble adding an image t, Glen Mazza | Thread | Re: [xsl] Trouble adding an image t, J.Pietschmann |
Re: [xsl] Trouble adding an image t, Glen Mazza | Date | [xsl] CDATA elements in XSLT, Dario Romero |
Month |