1

I am using FOP library to generate pdf from a xml file, able to generate all the data(except image) with dynamic info passed through another xml. Its not allowing me to pass image value as below

<fo:inline>  
          <fo:external-graphic content-width="109.5pt"
                                    content-height="50.25pt"
                                    src="<xsl:value-of select="paymentno" />"
            </fo:external-graphic >
</fo:inline>

where xml data which is being passed dynamically is

`<tns:paymentno>
"url(&quot;data:image/auto;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAAAoCAIAAAAAKyESAAAAYUlEQVR42u3PQQoAIAgEwP7/6YIiEC3oGownjWVjWt/T5qwlvqQz5utyKzkGUvJYlX55aahnjOUAPz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/P/+H/gGaQxUFTT6pUgAAAABJRU5ErkJggg==;&quot;)"</tns:paymentno>`

One more thing, if i am passing static value(of image) directly to xsl then i am able to get image in my pdf. Please do provide me with solution if you have any idea asap

2 Answers2

0

Your XSL is incorrect. You cannot just put xsl:value-of inline. See this answer for inspiration to write the template.

Inserting a base64 encoded image into xsl-fo file while using apache-poi

Community
  • 1
  • 1
Kevin Brown
  • 8,805
  • 2
  • 20
  • 38
0

You will be passing your result to an XSL function, so you can just read the value directly.

<fo:inline>
    <fo:external-graphic
        content-width="109.5pt"
        content-height="50.25pt"
        src="url({paymentno})">
    </fo:external-graphic >
</fo:inline>

If you really wanted to use value-of, then you will use it to set an xsl attribute. From memory this should be (untested):

<fo:inline>
    <fo:external-graphic
        content-width="109.5pt"
        content-height="50.25pt">

        <xsl:attribute name="src">
            <xsl:value-of select="paymentno"/>
        </xsl:attribute>

    </fo:external-graphic>
</fo:inline>
MeltedPenguin
  • 787
  • 7
  • 17
Jack
  • 16,506
  • 19
  • 100
  • 167