After testing various complicated solutions to embed a QR Code into iReport Jasper reports, the easiest way I’ve found is this:
1) Put ZXing’s Core and JavaSE jars in the classpath (using Tools/Options/Classpath if compiling locally, or the classpath property if using Ant and net.sf.jasperreports.ant.JRAntCompileTask)
2) Add an image to your report with the following settings:
- Expression Class:
java.awt.Image
- Image Expression :
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( new com.google.zxing.qrcode.QRCodeWriter().encode( $F{CONTENT_TO_ENCODE}, com.google.zxing.BarcodeFormat.QR_CODE, 300, 300))
Of course, replace $F{CONTENT_TO_ENCODE} with your actual content.
3) Compile the report and enjoy !
Gracias!! sirvio de mucho..Thanks a lot bro!!
You’re welcome ! :)
You are the Bomb!, this rocks.
It’s easy Thanks!
Awesome, man. Works perfectly!
Thanks.
If use jasper server: http://stackoverflow.com/questions/12799975/custom-jar-file-on-jasper-server
Si subes tu reporte a jasper server con tomcat, necesitas copiar estos dos archivo en jasperreports-server-xx-x.x.x/apache-tomcat/webapps/jasperserver/WEB-INF/lib
Recuerda reiniciar el jasper server.
——
In order to run this report in jasper server. You need to copy this files to jasperreports-server-xx-x.x.x/apache-tomcat/webapps/jasperserver/WEB-INF/lib
Don’t forget to restart jasperserver
Thank you, this works as expected but how can I set the error correction level?
Exelent, ver y very easu. thanks
Thank you. It´s the easy way.
Thanks so much for that. Keep up the Good Work!
It works beautifully,tnx :)
Matalino! Salamat
Thank you, how to about how to generate 2d pdf417 in ireport ???
Thank! Easiest way!
Thanks!! It worked perfectly!
Thank you so much TvT
it working fine but when deploy on tomcat the report not working
but not support Arabic lang.
La derrière version :
https://mvnrepository.com/artifact/com.google.zxing/core/3.4.1
https://mvnrepository.com/artifact/com.google.zxing/core/3.4.1
Thank you! It helps a lot :)
2021 and this tutorial still effective. Thanks.
Haha thanks Allan :)
Funnily enough it’s the most visited page on my little blog !
Thanks a lot its working fine please let me know how to add two values to the
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
new com.google.zxing.qrcode.QRCodeWriter().encode(
$F{CONTENT_TO_ENCODE},—can we added tow values to this ?
com.google.zxing.BarcodeFormat.QR_CODE, 300, 300))
Buenas con relación a este tema, alguno sabra porque me da este error al ejecutar el reporte:
Error filling print… Error evaluating expression : Source text : com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage( new com.google.zxing.qrcode.QRCodeWriter().encode( $F{CD_PERSONA_CONTRATANTE}, com.google.zxing.BarcodeFormat.QR_CODE, 300, 300 ) )
Gracias!!!