Need help in displaying image in PDF using XSL-FO and data URI scheme

image, java, pdf, xsl-fo, xslt

Solution

Is your issue that the `$imageData` isn't being output with the values, just the string literal "$imageData"?

When you are inside of an attribute and want to evaluate the value of the variable, you need to use an attribute value template. Wrap the variable with curly braces.

<fo:external-graphic src="data:image/jpeg;base64,{$imageData}"/>

Problem

For the DATA, if i set the base64 encoded string in a parameter, ``` String imageData = Base64.encode(IOUtils.toByteArray(is)); transformer.setParameter("imageData", imageData); ``` and use the parameter in xslt like this, ``` <fo:external-graphic src="data:image/jpeg;base64,$imageData"/> ``` I tried with url and without url and both doesn't seem to work. Please help me. I am struggling to get the image on the pdf for over a month now.

Original source