Saturday 21 February 2015

Generating QR Codes in AX 2009

Hi Friends,
Recently I worked on a task to generate and show QR code on a report in AX 2009.

In order to do this, I did the below steps:
  • Downloaded file MessagingToolkit.QRCode.dll
  • Copied it in client\bin folder

  • Added this dll file in the system references


  • Create a new display method on the report. The below code can be used to generate QR code.
display container qrcode()
{
    Bindata                 bindata = new Bindata();
    Image                   Imgobj;
    System.Drawing.Image    img;
    System.Drawing.Bitmap   obj;
    Filepath                _path;
    container               con;
    MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
    ;
    obj = new System.Drawing.Bitmap(encoder.Encode("TESTSTRING"));
    obj.Save(@"C:\temp\newPhoto.bmp",System.Drawing.Imaging.ImageFormat::get_Bmp());
    bindata.loadFile(@"C:\temp\newPhoto.bmp");
    con = bindata.getData();
    return con;
}


  • Add the image control on the report based on the display method. 



QR code can be seen on the report on running it.



There are many other dll files available as open source to generate QR code. Keep sharing.

Reference: I found a link to do the same on AX2012