Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QR Code in BIRT

Tags:

birt

I want to generate QR code in BIRT . Before generating report I will enter number of labels as an input say x,then report should contain x labels along with QR code.QR code data is dynamic and based on input.I searched alot on web but not proper solution found.I want report like below

like image 676
Smita Ahinave Avatar asked Mar 14 '23 09:03

Smita Ahinave


1 Answers

The QRCode itself can be created using ZXing library using for example this tutorial.

In this example a small generator using zxing is developed to keep scripts as simple as possible but this is facultative, you could put all the java stuff directly into BIRT scripts. Here is basically what this script looks like:

importPackage(Packages.java.awt);
importPackage(Packages.org.my.package.using.zxing);

var url="Generate a URL or a message with data bindings, report parameters etc.";
try{
  vars["QRCode"]=QRcodeGenerator.getImage64QR(url, Color(params["QRColor"].value), Color.WHITE,params["QRSize"].value); 
}catch(e){
  vars["QRexception"]=e.message;
}

In your case a similar script could be put in a data binding of a dynamic image, or in a onCreate event, etc. At this point there are two options:

  • Generate a different temporary .png or .jpg for each dataset row, and set a native BIRT image element with an URI expression returning this temporary file
  • Generate a base64 image for each dataset row and embed it in a Dynamic image element or a HTML text element

The example is using the second approach with a HTML text element and an expression such:

<img alt="This QRCode can't be displayed" src='<VALUE-OF>vars["QRCode"]</VALUE-OF>'/>
like image 126
Dominique Avatar answered Apr 04 '23 20:04

Dominique