This is an XSL-FO question. I have a image which I have programmatically
generated using Java. I wish to embed this into a PDF document.
I know that we can embed image files into XSL-FO. But is there a solution
wherein I can add image represented as byte array from a java program into
PDF?. Writing a byte array into a file and embedding this file may not be a
very efficient solution.
Thanks,
> I know that we can embed image files into XSL-FO. But is there a solution
> wherein I can add image represented as byte array from a java program into
> PDF?. Writing a byte array into a file and embedding this file may not be
> a very efficient solution.
In XSL-FO, images are referenced by URLs; and URLs can contain
the actual data using the "data" URL scheme [RFC 2397,
http://www.ietf.org/rfc/rfc2397.txt]. However, you should
check if your XSL-FO formatter supports "data" scheme.
There is no built-in support for this URL type in Java, so
you don't get it granted.
My company's product, RenderX XEP, supports data URLs.
Best regards,
Nikolai Grigoriev
RenderX
<fo:external-graphic content-height="10em" content-width="13em" src="url({$urlImagen})"/>
where urlImagen, is something like:
<xsl:variable name="urlImagen">
data:image/auto;base64,
<xsl:value-of select="java:com.tragsega.promis.graficos.ImgCreator.getEncodedString('${nombre}','/img/')"/>
</xsl:template>
It works. Be sure to have appropiate jars (xalan extensions)