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 !

7 comments on “iReport: adding QRCode to Jasper reports the easy way

  1. 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

Leave a Reply

news for few, stuff no-one cares about