Con Skordis · Jan 26, 2022

Using XSLT to add background image

I have a PDF ZEN report module that I'm using XslFoXslt to highlight the table cell.

What I need is for a particular value to add a background image to the <item> that is calling the XSLFoXslt

The code I have is the following but all that happens is the color. 

XData XslFoXslt
<xsl:template name="HighLight">
<xsl:param name="Value"/>

<xsl:if test="$Value = 400">
<xsl:attribute name='background-image'>url("images/trash-icon.png")</xsl:attribute>
<xsl:attribute name='background-repeat'>no-repeat</xsl:attribute>
<xsl:attribute name='color'>#ffffff</xsl:attribute> </xsl:if>


Product version: Caché 2018.1
0 606
Discussion (7)1
Log in or sign up to continue

Hi Con

I think your problem might be that background-image and background-repeat are CSS properties, not HTML attributes.  Color works because it is an HTML attribute (although you should use the CSS style property for this as well these days).


<xsl:if test="$Value = 400">
     <xsl:attribute name='style'>background-image: url("images/trash-icon.png"); background-repeat: no-repeat;</xsl:attribute>
     <xsl:attribute name='color'>#ffffff</xsl:attribute>

If that works then you might want to consider using a class attribute to reference a stylesheet rather than including a style attribute directly, but that's another matter.


Thanks George but unfortunately the pdf fails to render.

Hi Con

Check the url reference to the image.


Hi Con

Actually, xsl-fo has it's own way of styling so what I suggested, which would work for html, probably isn't applicable for xsl-fo.


Thank you for your time on this.


With reference the PDF errors and does not appear at all.


If there is no way to add image to the XSLT template, is it possible to add &#8593; for up arrow?