I am generating the JasperReport for my billing desktop application using JAVA but, I can't see the QR Code icon in the report in jasper 6.0.3 version; In the preview it is showing the QR Code, but not in the real report.
Please can anyone suggest the idea and QR Code JAR files?
I am writing my answer very late. But I think zxing is the best open source library for generating the QR code. Here I am writing how you can generate QR code using zxing library in Java. I am using iReport as designer tool.
Step 1: Add 2 jar files in class path of iReport (Tools > Options > iReport Tab > Classpath Tab > Add Jar)
a) zxing-core
from https://mvnrepository.com/artifact/com.google.zxing/core/3.3.1
b) zxing-javase
from https://mvnrepository.com/artifact/com.google.zxing/javase/3.3.1
Note: You may choose latest jar's. I am using latest as of date
Screen shot of adding jar in class path
Step 2: Create a parameter / field (as per your need). I am using a parameter. Let us call it qrCode.
Step 3: Drag and drop an image from palette panel of iReport designer (In windows it is accessible through Shift + ctrl + 8
). And choose Cancel (We do not want static image).
Step 4: Select the image by clicking on it. You will see the properties tab in right side.
a) Choose Expression Class as java.awt.Image
b) Click on Image Expression property. And fill the expression as
com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
new com.google.zxing.qrcode.QRCodeWriter().encode(
$P{qrCode},
com.google.zxing.BarcodeFormat.QR_CODE, 300, 300
)
)
Note: If you want to use field
instead of parameter
just replace the parameter
with field
in expression.
Step 5: Compile report and run.
To read about different usage go through the post Generate QR code in Java using zxing