QR is the trademark for a type of matrix barcode (or two-dimensional barcode) first designed for the automotive industry in Japan. This QR code is also used in automobiles. If customer wanst to know about the part details, then only a mobile app is needed to read it. We are using QR code to read all data with security.
A company gives a customer security key for reading QR code. My project came and said I want a QR code with Security key. So I decided make a QR code using C#. I know in C# we have a lot of DLL (library) or Third party software also available in market to make QR codes.
I have created one image to display the QR code in report, this image binds in RDLC report.
Bind image in report.

Figure: Showing how to bind image
One question arises, that this is a static way, not dynamic. But don't worry we can pass image parameters according to our requirement.
// Bind the image dynamically in parameters.
ReportParameter parameter = new ReportParameter(
"QR_Img",
"file:\\" + Application.StartupPath + "test.png",
true
);
Page setting as per requirement.
System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
// Margin Top set here...
pg.Margins.Top = 1;
// Margin bottom set here
pg.Margins.Bottom = 1;
// Margin left set here
pg.Margins.Left = 0;
// Margin right set here
pg.Margins.Right = 0;
reportViewer1.SetPageSettings(pg);
// Hide the print button
this.reportViewer1.ShowPrintButton = false; // if you want print button on show in preview then set True here..
this.reportViewer1.RefreshReport();
// Set the parameters in report viewer
this.reportViewer1.LocalReport.SetParameters(parameter);
// Refresh here... clear all old values..
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
Create the QR code.
// Set information
string code = "Your information you want display in QR code";
QRCodeGenerator qrGenerator = new QRCodeGenerator();
// Create QR code
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
// Pass the reference in bitmap
using (Bitmap bitMap = qrCode.GetGraphic(20))
{
using (MemoryStream ms = new MemoryStream())
{
bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
using (MemoryStream ms1 = new MemoryStream(byteImage))
{
img = Image.FromStream(ms1);
}
img = ResizeImage(img, 150, 150);
RectangleF rectangleF = new RectangleF(10f, 0.0f, 0.0f, 0.0f);
Image MyImage = new Bitmap(img);
using (Graphics g2 = Graphics.FromImage(MyImage))
{
IntPtr dc2 = g2.GetHdc();
g2.ReleaseHdc(dc2);
}
// Image save here...
MyImage.Save(Application.StartupPath + "test.png", System.Drawing.Imaging.ImageFormat.Jpeg);
// Change the save path of image... like this way
}
}
Your QR Image is ready to display information.

After completing everything, ready your report for printing.

Above report aligns and sets according to our requirement. We are using TVS LP-45 printer.
I used in this project INI file. So please update your database information in INI file. You can get INI file in bin folder.

I hope all points are clear. If you have any query drop it in the comment section below.
Download demo project.
Read more articles on C# Programming.

rani bkPosted Jun 24, 2021, 11:49 AM
Not able to download the Project as it shows the project is no more available
rani bkPosted Jun 24, 2021, 11:48 AM
What are the Libraries to use
Fahmi rifaiPosted Oct 1, 2018, 9:55 PM
Please reupload demo project, i'can't download for now
Maulik MananiPosted Jun 7, 2018, 12:06 AM
Please update demo link project
R O D OPosted Jan 8, 2018, 4:14 PM
Good work, Share your code.
hamza bennaniPosted Nov 8, 2017, 5:14 AM
The demo link is not working
Rahul Kumar SaxenaPosted Apr 4, 2016, 7:48 AM
Goos Show
Onsel AYDINPosted Mar 29, 2016, 7:28 PM
like
kalu singh raoPosted Mar 29, 2016, 12:28 PM
Nice...
Kashif SohailPosted Mar 29, 2016, 2:53 AM
Nice one, informative
Debasis SahaPosted Mar 29, 2016, 12:16 AM
Good One..
Humayun Kabir MamunPosted Mar 29, 2016, 12:14 AM
Nice...
Saillesh PawarPosted Mar 28, 2016, 10:59 AM
Sample project will help.. :)
Ravi KandelPosted Mar 28, 2016, 6:00 AM
I want scanning one. Help me please
Vignesh ManiPosted Mar 28, 2016, 5:22 AM
Good
Mohammed IbrahimPosted Mar 28, 2016, 4:06 AM
nice