Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / ELandAX blog / How to print a QR code on S...

How to print a QR code on SSRS report

Hello AX World,

Generating a QR code to an SSRS report is easy.

There is a standard library in ApplicationSuite for QR code generation.

using Microsoft.Dynamics.ApplicationSuite.QRCode;

One important note: if you are working with 8.1 you will need to apply the update KB 4494407 as the library has a bug. 

Create QR Code

1. QR code generator creates an image out of the text so you need an image (container) type field on your report data source table. 

2. Once you have the field, the generation can be performed with a one-liner.

reportTableTmp.QRCode = new EFDocQRCode_BR().generateQRCode("ELANDAX");

If you don't want to use this class, you can copy the code from inside and use that. Don't forget to use the library.

using Microsoft.Dynamics.ApplicationSuite.QRCode;

try
{
    Encoder qrCodeEncoder = new Encoder();
    using(System.Drawing.Bitmap bm = qrCodeEncoder.Encode("ELANDAX"))
    {
        using (var stream = new System.IO.MemoryStream())
        {
            bm.Save(stream, System.Drawing.Imaging.ImageFormat::Png);
            reportTableTmp.QRCode Binary::constructFromMemoryStream(stream).getContainer();
        }
    }
}
catch (Exception::CLRError)
{
    throw error(CLRInterop::getLastException().ToString());
}


3. The last step is to add an image to an SSRS report.
I recommend setting image's Sizing property to Fit proportional as the generated image is rather small. 


Here you go, you have a QR code.



Be aware and take care!

Comments

*This post is locked for comments