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

9 comments:

  1. Please help me I am facing a problem when the string to be encoded is very long. Is there any string limit for which we are passing.

    ReplyDelete
    Replies
    1. Hi,

      Are you getting the solution for this as we are also stuck @ same point.

      Pl. help.


      Regards,
      Amol.

      Delete
  2. MessagingToolkit.QRCode.dll I couldnot download correct one. Where is the link i get it.

    ReplyDelete
  3. Problem when string to be encoded is very long i.e. more than 110 characters. Is there any string limit for which we are passing?

    ReplyDelete
  4. Hi, I had used

    Microsoft.Dynamics.QRCode.Encoder encoder = new Microsoft.Dynamics.QRCode.Encoder(); instead of the below code
    MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();

    This is not working for me, how can i sort out the issue.

    ReplyDelete
  5. MessagingToolkit.QRCode.dll I could not download correct one. Where is the link i get it.

    ReplyDelete
  6. my team is trying to create QR Code in Sales Invoice in AX2009. He is not able to see the reference page. Please help kranthiv@fli-me.com

    ReplyDelete