How to Add QR Code in Jasper Reports - By Wide Info Blog. To Add a QR Code, we need two jars - ZXing’s Core and JavaSE jars in the classpath in iReport (Jasper). Download Jars = Click Here, & save on your PC. Here are the steps for adding QR code in Jasper reports:
Step - 1. Open iReport Designer & add two jars - ZXing’s Core and JavaSE jars in the classpath - (Jasper Report >> Tools >> Options >> Classpath). Now click on "add jar" & select the jar location from your PC as shown below.
Step - 2. Now add image to your report with following settings:-
Expression Class: java.awt.Image (as shown below)
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))
Now Copy & paste above code in Image Expression. Where $F{CONTENT_TO_ENCODE} is the field that you want in your QR code.
But with this method it works well in JASPER VIEW but when we export it to pdf QR Code image is shown black
ReplyDelete