Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET Barcode > Barcode Generation Guide > .NET QR-Code Generator for .NET, ASP.NET, C#, VB.NET
Download Barcode for .NET Suite Trial

.NET QR-Code Generator for .NET, ASP.NET, C#, VB.NET

QR-Code Bar Code Generation Guide in .NET, C#, ASP.NET, VB.NET
  • Easily generate QR-Code barcodes in .NET applications
  • Compatible with the latest QR-Code ISO specification [ISO/IEC 18004 (Second edition 2006-09-01)]
  • Generate high quality QR-Code images in JPEG, GIF & PNG formats
  • 100% build in C#, compatible with .net 2.0 and later version
  • Generate QR-Code barcodes using C#, VB.NET on ASP.NET or Windows Forms
  • Generate QR-Code in Crystal Reports using C#, VB.NET
  • Generate QR-Code in Reporting Service using C#, VB.NET
  • Mature .NET Barcode Generator component since 2003
  • Royalty-free and perpetual developer license
.NET QR-Code Barcode Introduction
QR-Code is also known as Denso Barcode, QRCode, Quick Response Code, JIS X 0510, ISO/IEC18004.
Compatibility: Barcode for .NET component is compatible with ISO/IEC 18004 (Second edition 2006-09-01).
QR Code is a kind of 2-D (two-dimensional) symbology developed by Denso Wave (a division of Denso Corporation at the time) and released in 1994 with the primary aim of being a symbol that is easily interpreted by scanner equipment.
QR Code is capable of handling all types of data, such as numeric and alphabetic characters, Kanji, Kana, Hiragana, symbols, binary, and control codes.
The symbol versions of QR Code range from Version 1 to Version 40. Each version has a different module configuration or number of modules (the module refers to the black and white dots that make up QR Code). "Module configuration" refers to the number of modules contained in a symbol, commencing with Version 1 (21 x 21 modules) up to Version 40 (177 x 177 modules). Each higher version number comprises 4 additional modules per side. Each QR Code symbol version has the maximum data capacity according to the amount of data, character type and error correction level. In other words, as the amount of data increases, more modules are required to comprise QR Code, resulting in larger QR Code symbols.
QR Code has error correction capability to restore data if the code is dirty or damaged. Four error correction levels are available for users to choose according to the operating environment. Raising this level improves error correction capability but also increases the amount of data QR Code size. To select error correction level, various factors such as the operating environment and QR Code size need to be considered. Level Q or H may be selected for factory environment where QR Code gets dirty, whereas Level L may be selected for clean environment with the large amount of data. Typically, Level M (15%) is most frequently selected. The QR Code error correction feature is implemented by adding a Reed-Solomon Code to the original data.
.NET QR-Code Basic Characteristics
QR Code is a matrix symbology with the following characteristics:
  1. Formats: QR Code, with full range of capabilities and maximum data capacity;
  2. Encodable character set:
    • numeric data (digits 0 - 9);
    • alphanumeric data (digits 0 - 9; upper case letters A -Z; nine other characters: space, $ % * + - . / : );
    • byte data (default: ISO/IEC 8859-1);
    • Kanji characters.
  3. Version (Symbol size) (not including quiet zone): 21 x 21 modules to 177 x 177 modules (Versions 1 to 40, increasing in steps of four modules per side).
  4. Maximum QR Code symbol size, Version 40-L:
    • numeric data: 7089 characters
    • alphanumeric data: 4296 characters
    • Byte data: 2953 characters
    • Kanji data: 1817 characters
  5. Selectable error correction level:
    Four levels of Reed-Solomon error correction (referred to as L, M, Q and H in increasing order of capacity) allowing recovery of:
    • L 7% of the symbol codewords
    • M 15% of the symbol codewords
    • Q 25% of the symbol codewords
    • H 30% of the symbol codewords
  6. Structured Append: This allows files of data to be represented logically and continuously in up to 16 QR Code symbols.These may be scanned in any sequence to enable the original data to be correctly reconstructed.
  7. Extended Channel Interpretations: This mechanism enables data using character sets other than the default encodable set (e.g. Arabic,Cyrillic, Greek) and other data interpretations (e.g. compacted data using defined compression schemes)or other industry-specific requirements to be encoded.
  8. FNC1 Mode: FNC1 mode is used for messages containing specific data formats. In the "1st position" it designates data formatted in accordance with the GS1 General Specifications. In the "2nd position" it designates data formatted in accordance with a specific industry application previously agreed with AIM Inc. FNC1 mode applies to the entire symbol and is not affected by subsequent mode indicators.
.NET QR-Code Encoding Data Scope
QRCode Barcode for .NET, ASP.NET supports:
  • numeric data (digits 0 - 9);
  • alphanumeric data (digits 0 - 9; upper case letters A -Z; nine other characters: space, $ % * + - . / : );
  • byte data (default: ISO/IEC 8859-1);
  • Kanji characters.
How to Generate QR Code Barcode Image in IIS without Visual Studio .NET?
  1. Under downloaded trial package, copy barcode folder to your IIS folder, e.g. C:\Inetpub.
  2. Create a new virtual directory in IIS, named barcode, and link to the above "barcode" folder.
  3. Restart IIS.
  4. To test your installation, open your web browser and navigate to:
    http://YourDomain:port/barcode/qrcode.aspx?Data=0123456789&ModuleSize=3&LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12
  5. To create barcode image in your aspx or html page, you need pass the url to IMG tag src value.
    For example:
    <img src="http://YourDomain:port/barcode/qrcode.aspx?Data=0123456789&ModuleSize=3&LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12" />
    Using this method, it will not generate any barcode images in your IIS server side.
How to Generate QR Code Barcode Image through ASP.NET Web Form Control?
  1. Install .NET Barcode Controller to your ASP.NET project.
    • Add Reference BarcodeLib.Barcode.ASP.NET.dll to your project.
      Do not copy the dll to the bin directory, Visual Studio will do so, during project compilation time.
  2. Add barcode library to your Visual Studio Toolbox.
    • Open Toolbox in Visual Studio. Click menu View, and check submenu Toolbox.
    • Right click Toolbox, click menu Choose Items...
    • Goto .NET Framework Components tab.
    • If no BarcodeLib component found, click Browse... button and select BarcodeLib.Barcode.ASP.NET.dll file.
    • Then sort "Namespace" column, you will find 4 components from BarcodeLib.Barcode.
    • Check component LinearASPNET, and its namespace is BarcodeLib.Barcode.
    • Click "OK" button, you will find four components under "General": LinearASPNET.
  3. Go to "barcode" folder in the trial package, copy file "linear.aspx" to the same folder as your aspx page, which will generate barcodes.
  4. You can drag LinearASPNET on your aspx page in design view, change barcode setting through properties window.
  5. Run the project, you will find barcode images generated in your aspx pages.
How to Generate QR Code Barcode Image through .NET Windows Form Control in C# or VB.NET?
  1. Add Reference BarcodeLib.Barcode.WinFroms.dll to your project. Do not copy the dll to the bin directory, Visual Studio will do so, during project compilation time.
    • In your .NET windows project, right click mouse over Refereces in your Solution Explorer window. Then click menu "Add Reference ...".
    • Add BarcodeLib.Barcode.WinFroms.dll to your project.
  2. Add barcode library to your Visual Studio Toolbox.
    • Open Toolbox in Visual Studio. Click menu View, and check submenu Toolbox.
    • Right click Toolbox, click menu Choose Items...
    • Goto .NET Framework Components tab.
    • If no BarcodeLib component found, click Browse... button and select BarcodeLib.Barcode.WinFroms.dll file.
    • Then sort "Namespace" column, you will find 4 components from BarcodeLib.Barcode.
    • Check component LinearWinForm, and its namespace is BarcodeLib.Barcode.
    • Click "OK" button, you will find the control under "Common Controls": LinearWinForm.
  3. Now you can see the component displayed on Toolbox. You can drag LinearWinForm on your form, change barcode setting through properties widnow.
How to Generate QR Code Barcode Image in .NET/C#/VB.NET class?
  1. Add Reference BarcodeLib.Barcode.ASP.NET.dll or BarcodeLib.Barcode.WinFroms.dll to your .NET project (ASP.NET website, Forms, any .NET project).
    In your .NET class:
     BarcodeLib.Barcode.QRCode barcode = new BarcodeLib.Barcode.QRCode();
barcode.Data = "123456789012";

barcode.ModuleSize = 3;
barcode.LeftMargin = 0;
barcode.RightMargin = 0;
barcode.TopMargin = 0;
barcode.BottomMargin = 0;

barcode.Encoding = BarcodeLib.Barcode.QRCodeEncoding.Auto;
barcode.Version = BarcodeLib.Barcode.QRCodeVersion.V1;
barcode.ECL = BarcodeLib.Barcode.QRCodeErrorCorrectionLevel.L;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

// more barcode settings here

// save barcode image into your system
barcode.drawBarcode("c://barcode.png");

// generate barcode & output to byte array
byte[] barcodeInBytes = barcode.drawBarcodeAsBytes();

// generate barcode to Graphics object
Graphics graphics = ...;
barcode.drawBarcode(graphics);

// generate barcode and output to HttpResponse object
HttpResponse response = ...;
barcode.drawBarcode(response);

// generate barcode and output to Stream object
Stream stream = ...;
barcode.drawBarcode(stream);
Above code written in C# 2005
How to Save QR-Code Barcode Image using .NET Barcode Generator Windows Control?
In Windows Controller, just call method SaveAsImage(string filename). e.g. SaveAsImage("C:\barcode.gif");
.NET QR-Code Barcode Property Settings
  1. Set the Data property with the value to encode. Type is string.
    Web Stream URL Parameter: Data.
  2. Set the Encoding property. Default is QRCodeEncoding.Auto.
    • QRCodeEncoding.Auto: It allows encoding all 256 possible 8-bit byte values. This includes all ASCII characters value from 0 to 127 inclusive and provides for international character set support
    • QRCodeEncoding.AlphaNumeric: It allows encoding alphanumeric data (digits 0 - 9; upper case letters A -Z; nine other characters: space, $ % * + - . / : ).Web Stream URL Parameter: Encoding. Valid values are: 0 (Auto), 1 (AlphaNumeric), 2 (Byte), 3 (Numeric), 4 (Kanji).
    • QRCodeEncoding.Byte: It allows encoding byte data (default: ISO/IEC 8859-1).
    • QRCodeEncoding.Numeric: It allows encoding numeric data (digits 0 - 9).
    • QRCodeEncoding.Kanji: It allows encoding Kanji characters.
  3. Set the Version property. Default is QRCodeVersion.V1.
    About Version and Symbology Size
    Web Stream URL Parameter: Version. Valid values are: (int)QRCodeVersion
  4. Set the ECL property. QRCode Error Correction Level. Default is QRCodeErrorCorrectionLevel.L (0).
    About Error Correction Level
    Web Stream URL Parameter: ECL. Valid values are: 0 (L), 1 (M), 2 (Q), 3 (H).
    • QRCodeErrorCorrectionLevel.L (0)
    • QRCodeErrorCorrectionLevel.M (1)
    • QRCodeErrorCorrectionLevel.Q (2)
    • QRCodeErrorCorrectionLevel.H (3)
  5. QR Code can be divided into multiple data areas. Conversely, information stored in multiple QR Code symbols can be reconstructed as single data symbols.One data symbol can be divided into up to 16 symbols.
    • SetEnableStructuredAppend property to true, then Structured Append is enabled.
      About Structure Append
      Web Stream URL Parameter: EnableStructuredAppend.
      Valid values are: "true", or "false".
    • Set StructuredAppendCount property to the number of total symbols which make the sequence.
      Web Stream URL Parameter: StructuredAppendCount.
    • Set StructuredAppendIndex property to the position of current symbol in the secuence (Start with 1).
      Web Stream URL Parameter: StructuredAppendIndex.
  6. Set the FNC1Mode property.
    About FNC1 Mode
    Web Stream URL Parameter: FNC1Mode. Valid values are: 0 (NotSupported), 1 (FirstPosition), 2 (SecondPostion).
    • QRCodeFNC1Mode.NotSupported (0)
    • QRCodeFNC1Mode.FirstPosition (1)
    • QRCodeFNC1Mode.SecondPostion (2)
  7. Set the ApplicationIndicator property. Please set this property, if property FNC1Mode value is QRCodeFNC1Mode.SecondPostion (2).
    Web Stream URL Parameter: AI.
  8. Set the ECI property. The type is int. Valid values are from 000000 to 999999. About Extended Channel Interpretations
    Web Stream URL Parameter: ECI.
  9. Set the ProcessTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is false.
    ~NNN: is used to represent the ASCII character with the value of NNN.
    Web Stream URL Parameter: ProcessTilde. Valid values are: "true", or "false".
  10. Barcode Size Settings.
    • Set property UOM (Unit of Measure) for properties BarWidth, BarHeight, LeftMargin and TopMargin.
      Valid values are UnitOfMeasure.Pixel (0), UnitOfMeasure.CM (1), UnitOfMeasure.Inch (2).
      Default is UnitOfMeasure.Pixel (0).
      Web Stream URL Parameter: UOM. Valid values are: 0, 1, 2.
    • Set the ImageWidth and ImageHeight properties.
      Both types are float.
      BarWidth default is 0 pixel.
      BarHeight default is 0 pixel.
      Web Stream URL Parameter: ImageWidth and ImageHeight.
    • Set the ModuleSize (for bar cell width and height)
      Type is float.
      Default is 3 pixels.
      Web Stream URL Parameter: ModuleSize.
    • Set the LeftMargin, RightMargin, TopMargin and BottomMargin properties.
      Types are all float. Default are 0.
      Web Stream URL Parameter: LeftMargin, RightMargin, TopMargin, BottomMargin.
    • Set the ResizeImage property to "true" and our component will resize the barcode image if manual setting is invalid.
      Type is bool. Default is false.
      Web Stream URL Parameter: ResizeImage.
    • Set the Resolution property (Value is expressed in DPI - Dots per inch).
      Type is int. Default is 96 dpi.
      Web Stream URL Parameter: Resolution.
  11. Set Color Related properties.
    • Set the BackgroundColor property. Barcode background color can be changed.
      Type is System.Drawing.Color. Default is BackgroundColor = Color.White.
      Web Stream URL Parameter: BackgroundColor.
    • Set the ModuleColor property. Barcode bars color can be changed.
      Type is System.Drawing.Color.Default is ModuleColor = Color.Black.
      Web Stream URL Parameter: ModuleColor.
  12. Set the ImageFormat property for barcode image type.
    • Type is System.Drawing.Imaging.ImageFormat.
      Default value is ImageFormat.Png.
      Web Stream URL Parameter: ImageFormat. Valid values are: gif, jpeg, png, bmp, tiff.
All Supported .NET Barcode Symbologies
Generate Linear Barcodes:
Generate 2D Barcodes: