How to print a QR code on SSRS report - Song Nghia - #Open To Relocate

Dynamics 365 Outsourcing Service

Thứ Bảy, 5 tháng 12, 2020

How to print a QR code on SSRS report

 How to print a QR code on SSRS report


Nghia Song -  Microsoft Dynamics 365 Technical Consultant

Nghia Song

Tel - WhatsApp: +84967324794


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;

    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.