Using a Quick Response code to link to content
A Quick Response (QR) code is a type of two-dimensional bar code that contains encoded information. Figure 5‑17 shows an example of a QR code.
Figure 5‑17 A QR code
QR codes are used by a wide range of applications targeted to document management and mobile phone users. QR codes can store URLs, business card information, contact details, meeting schedules or any kind of text. Use a QR code in a report to provide contact information or links to other reports. Mobile phone users who have a QR code reader on their phone can scan the image of a QR code to display the contact information or open a report.
BIRT Designer Professional includes a QR code generator, for generating QR codes. To insert a QR code in a report, insert an image element to display the QR code. In the image’s onCreate or onRender event, write code to dynamically create the QR code.
To test QR code generation in BIRT Designer Professional, add core.jar or the most recent version of it to your Resources folder. This JAR file is available from the ZXing library at following URL:
The code example in Listing 5‑3 creates a QR code that, when scanned, opens a report, qrreport.rptdesign, on a BIRT iHub.
Listing 5‑3 Code to create a QR code that opens a report
var size = 350; // image width and height in pixels
var bgnd = new, 1.0, 1.0); // white background
var fgnd = new, 0, 0); // black foreground
// Report URL to encode.
var message = "http://athena:8700/iportal/;"
var writer = new;
var matrix = writer.encode(message,, size, size);
var bi = new, size,;
var g = bi.getGraphics();
for (var y = 0; y < size; y++) {
for (var x = 0; x < size; x++) {
if (matrix.get(x, y)) {
g.fillRect(x, y, 1, 1);
baos = new;
Packages.javax.imageio.ImageIO.write(bi, "png", baos); = baos.toByteArray();
QR codes support up to 4,296 characters. The higher the number of characters, the higher the resolution of the QR code. Note, however, that low‑resolution mobile phone cameras might have difficulty reading high‑resolution codes.