iReport: adding QRCode to Jasper reports the easy way

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 !

19
Leave a Reply

avatar
19 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
17 Comment authors
mahmoudALmonLatEHenrique Luis Schmidtlucasschmoellerdasilvareneelist Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of
DrJekill Gt
Guest

Gracias!! sirvio de mucho..Thanks a lot bro!!

Colin
Guest

You’re welcome ! :)

Armando
Guest
Armando

You are the Bomb!, this rocks.

Kudo
Guest
Kudo

It’s easy Thanks!

Mariano
Guest
Mariano

Awesome, man. Works perfectly!

Gerardo G
Guest
Gerardo G

Thanks.
If use jasper server: http://stackoverflow.com/quest.....per-server

Gerardo G
Guest
Gerardo G

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

Raul Mendez
Guest

Thank you, this works as expected but how can I set the error correction level?

abcd3883@hotmail.com
Guest
abcd3883@hotmail.com

Exelent, ver y very easu. thanks

Edgar
Guest
Edgar

Thank you. It´s the easy way.

abhijeet singh
Guest

Thanks so much for that. Keep up the Good Work!

f
Guest
f

It works beautifully,tnx :)

el programo
Guest
el programo

Matalino! Salamat

reneelist
Guest
reneelist

Thank you, how to about how to generate 2d pdf417 in ireport ???

lucasschmoellerdasilva
Guest

Thank! Easiest way!

Henrique Luis Schmidt
Guest

Thanks!! It worked perfectly!

ALmonLatE
Guest
ALmonLatE

Thank you so much TvT

mahmoud
Guest
mahmoud

it working fine but when deploy on tomcat the report not working

mahmoud
Guest
mahmoud

but not support Arabic lang.

news for few, stuff no-one cares about