IBACK
IBACK

Reputation: 39

XSL-FO : Image doesn't show in PDF File

this is my problem : my image doesn't show in my PDF file.

this is my XML file :

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Devis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="mon_fichier.xsd">
    <EnTete>
        <Logo>
            <img>file:/C:/mon_fichier.jpg</img>
        </Logo>
</EnTete>
</Devis>

This is my XSL File :

<xsl:template match="/">

...
    <fo:static-content flow-name="xsl-region-before"
                    font-size="12pt" font-family="Times New Roman">
        <fo:block>
         <xsl:param name="image" select="EnTete/Logo/img" />

         <fo:external-graphic src="{concat('url','(',$image,')')}"
            content-height="80px" content-width="640px" />
        </fo:block>
    </fo:static-content>

...

</xsl:template>

Any ideas ?

thank you in advance.

FM

Upvotes: 0

Views: 928

Answers (2)

lfurini
lfurini

Reputation: 3788

I see a few points that you should check:

  • the xsl:param declaration is not in a valid position, it should be right after the xsl:template; if you never actually pass a value to the template and always use the selected one, you could use xsl:variable instead, and put it wherever you want
  • the XPath should be Devis/EnTete/Logo/img (or /Devis/EnTete/Logo/img, or //EnTete/Logo/img) if you want to select the image pathname in a template matching "/"
  • you don't mention what formatter you are using; if it's a recent version of Apache FOP, you don't have to put the image path inside url(...), just use <fo:external-graphic src="{$image}" content-height="80px" content-width="640px"/>
  • the image pathname in the XML file should probably be: file://C:/mon_fichier.jpg (with // instead of a single /)

Upvotes: 1

Hobbes
Hobbes

Reputation: 2115

The path in your XML is strange: file:/C:/mon_fichier.jpg should be C:\mon_fichier.jpg

And then this should work:

fo:external-graphic src="/Devis/EnTete/Logo/img"

The xsl:param in your XSL does nothing. Why is it there?

Upvotes: 0

Related Questions