Generate QR Code in Microsoft AX 2012
A quick way of generating a QR code from Microsoft Dynamics AX 2012.
In this tutorial, I am making use of AX 2012 R3.
A palpable example is printing a QR code for an Item.
Here is a simple job that would generate the phrase “Bonjour Monsieur Winner” as a QR code.
static void createQRCode(Args _args)
{
Microsoft.Dynamics.QRCode.Encoder qrCode;
System.String netString;
str tempFileName;
System.Drawing.Bitmap netBitmap;
Bitmap imageQR;
FileIOPermission perm;
BinData binData;
container imageContainer;
Image image;
;
netString = “Bonjour Monsieur Winner”;
qrCode = new Microsoft.Dynamics.QRCode.Encoder();
netBitmap = qrCode.Encode(netString); //encode the string as Bitmap can be used already
tempFileName = qrCode.GetTempFile(netString); //to get the QR temporary file
perm = new FileIOPermission(tempFileName,’r’);
perm.assert();
binData = new binData();
binData.loadFile(tempFileName);
imageContainer = binData.getData(); //get the QR code image put inside container so can be stored inside database for storing or reporting purpose
System.IO.File::Delete(tempFileName);
CodeAccessPermission::revertAssert();
// Saving the QR code as a PNG file
image = new Image();
image.setData(imageContainer);
image.saveImage(“D:\Monsieur.png”, ImageSaveType::PNG);
}
Merci 🙂
Your comment is awaiting moderation.
I enjoyed reading your piece and it provided me with a lot of value.