Nuclos Jasper QR code: ZXing, QRCodeWriter, core.jar, javase.jar, image expression, classpath, barcode. |
Language: Deutsch · English
Generate QR codes in reports – ZXing library, QRCode class, classpath and free customization of the image expression.
Auf dieser Seite |
A QR code is a 2D matrix with error correction (up to ~30% loss). In Nuclos forms it is generated via the ZXing library and a small helper class.
Google provides ZXing. Copy core.jar (folder Core) and javase.jar (folder Javase) into the project folder.
package com.qrcodeself;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
/**
*
* @author
*/
public class QRCodeClass{
public static java.awt.Image setQRCode(String code) {
QRCodeWriter writer = new QRCodeWriter();
BitMatrix matrix = null;
try {
matrix = writer.encode(code, BarcodeFormat.QR_CODE, 100, 100);
}catch (WriterException e){
}
return MatrixToImageWriter.toBufferedImage(matrix);
}
} |
Provide the class as a scriptlet/extension and register it in the Jasper classpath parameter.
Every base form contains a default QR code from the BO's abbreviation and number. The call is in the Image Expression property and can be composed freely (string concatenation with +):
"LS: " + $F{strnummer} |
String fields are recognizable by the |
Extended QR code values.