Last active
May 8, 2024 16:47
-
-
Save maravilloso/5763202 to your computer and use it in GitHub Desktop.
Embeber imágenes en base64 cuyo contenido se pasa como parámetro.
Mas información: http://rgauss.com/2009/12/21/jasperreports-xml-datasource-with-inline-images/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<import value="javax.imageio.ImageIO"/> | |
<import value="org.apache.commons.codec.binary.Base64"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
OJO: hay que especificar su TIPO y su momento de EVALUACION a "Report" | |
--> | |
<image scaleImage="RetainShape" evaluationTime="Report"> | |
... | |
<imageExpression class="java.awt.Image"><![CDATA[$V{IMGFIRMA64}]]></imageExpression> | |
</image> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
OJO: Es IMPORTANTE ponerle un valor POR DEFECTO para que no dé error | |
en tiempo de ejecución antes de que sea capaz de procesar | |
el valor de entrada de este parámetro. | |
--> | |
<parameter name="FIRMA64" class="java.lang.String"> | |
<parameterDescription><![CDATA[Imagen en base 64]]></parameterDescription> | |
<defaultValueExpression><![CDATA["/9j/4AAQSkZJRgABAQEAYABgAAD ... "]]></defaultValueExpression> | |
</parameter> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<variable name="IMGFIRMA64" class="java.awt.Image" resetType="None"> | |
<variableExpression><![CDATA[ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64($P{FIRMA64}.getBytes("UTF-8"))))]]></variableExpression> | |
</variable> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hola buenos dias, sería tan amable de mostrar el código también en java donde pasamos como parámetro la imagen en base64, por ver si existe alguna conversión que no realizo, se me pierde por algún sitio y no soy capaz.