Guide to Generate QR Code in C#.NET
Generate & create 2D QR Code barcode images in C#, ASP.NET web applications, and windows forms
- Easy integration into .NET applications to generate QR Code in C#.NET class library
- Print valid matrix barcode QR Code images in ASP.NET web sites and Windows Forms applications
- Draw and save QR Code bar codes in gif, jpeg, png, tiff, and bitmap formats with C#.NET programming
- Major 2D barcodes supported including QR Code, Data Matrix, PDF417, etc.
- Compatible with the latest ISO/IEC QR Code specifications to allow valid image output in .NET
- A variety of barcode options available including module width, height, resolution, orientation, ECL, data mode, etc.
QR Code Introduction
QR Code, also named as Denso Barcode, QRCode, Quick Response Code, JIS X0510, ISO/IE18004, is a popular matrix barcode with fast readability and large storage capacity.
QR Code Encodable Character Set:
- AlphaNumeric: 0 - 9, upper case letters A - Z, and nine punctuation characters space, $ % * + - . / :
- Byte data: (ISO/IEC 8859-1) encoding characters at 8 bits per character
- Kanji Characters
- Numeric: digits 0 - 9
QR Code Barcode Generation in C#.NET
Install QR Code Barcode for .NET Suite into your .NET Project
1.
Download K.A.Barcode for .NET Suite and unzip
2.
Add "KeepAutomation.Barcode.Windows.dll" or "KeepAutomation.Barcode.Web.dll" to reference
3.
Add "KeepAutomation.Barcode.Windows" or "KeepAutomation.Barcode.Web" to Visual Studio .NET ToolBox.
C# Demo Code to Generate QR Code in .NET Applications
using KeepAutomation.Barcode.Bean;
BarCode qrcode= new BarCode();
qrcode. Symbology = Symbology. QRCode;
// QR Code data mode, supporting AlphaNumeric, Auto, Byte, Customer, Kanji, Numeric
qrcode. QRCodeDataMode = QRCodeDataMode.Auto;
// Valid QR Code encoding data:
qrcode.CodeToEncode = "C#QRCodeGenerator";
// Unit of measure, pixel, cm and inch supported.
qrcode.BarcodeUnit = BarcodeUnit.Pixel;
// QR Code image resolution in dpi
qrcode.DPI = 72;
// QR Code bar module width (X dimention)
qrcode.X = 3;
// QR Code bar module height (Y dimention), Y=X
qrcode.Y = 3;
// QR Code image left margin size, the minimum value is 4X.
qrcode.LeftMargin =12;
// Image right margin size, minimum value is 4X.
qrcode.RightMargin = 12;
// Image top margin size, minimum value is 4X.
qrcode.TopMargin = 12;
// Image bottom margin size, minimum value is 4X.
qrcode.BottomMargin = 12;
// QR Code orientation, 90, 180, 270 degrees supported.
qrcode. Orientation = KeepAutomation.Barcode.Orientation.Degree0;
// QR Code barcode version, valid from V1-V40
qrcode.QRCodeVersion = QRCodeVersion.V5;
// QR Code barcode Error Correction Lever, supporting H, L, M, Q.
barcode.QRCodeECL = QRCodeECL .H;
// QR Code image formats, supporting Png, Jpeg, Gif, Tiff, Bmp, etc.
qrcode.ImageFormat = ImageFormat.Png;
// Generate QR Code barcodes in image format GIF
qrcode.generateBarcodeToImageFile("C://barcode-qrcode-csharp.gif");
// Create QR Code barcodes in Stream object
qrcode.generateBarcodeToStream(".NET System.IO.Stream Object");
// Draw & Print QR Code barcodes to Graphics object
qrcode.generateBarcodeToGraphics(".NET System.Drawing.Graphics Object");
// Generate QR Code barcodes & write to byte[]
byte[] barcodeInBytes = qrcode.generateBarcodeToByteArray();
// Generate QR Code barcodes & encode to System.Drawing.Bitmap object
Bitmap barcodeInBitmap = qrcode.generateBarcodeToBitmap();