birt

QR Code in 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


Solution

  • 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:

    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>'/>