Home > .NET Barcode > C# Barcode Generation Guide > C# QR-Code Generator for .NET, ASP.NET


C# QR-Code Generator Control for .NET

How to Generate QR-Code Barcodes in .NET applications using Visual C#


  • Simple to create 2D QR Code barcode in .NET projects using C#.NET
  • Completely built in Visual C#, compatible with .NET 2.0 and later versions
  • Generate QR Code Barcode in ASP.NET, WinForms using C#.NET programming
  • Paint, draw QR Code barcode in Crystal Reports, SSRS Reports and RDLC Reports
  • QR Code barcode images printed are in accordance with the latest ISO /IEC 18004 specification
  • Create high-quality QR Code barcode images in Png, Jpeg, Gif formats and save locally
  • C# demo code provided to control QR Code barcode format and size easily
  • Complete barcode settings to adjust various QR Code barcode parameters
  • C# Barcode Generator component provides royalty-free developer license for lifetime use

C# QR Code Introduction

QR-Code is also known as Quick Response Code, Denso Barcode, QRCode, JIS X 0510, ISO/IEC 18004.
Compatibility: Barcode for .NET component SDK is compatible with ISO/IEC 18004 (Second Edition 2006-09-01) bar code symbology specification.
QR Code barcode is a matrix (or two-dimensional) symbology designed by Denso Wave for the automotive industry. Now QR Code has grown popular due to its fast readability and large storage capacity, compared with linear barcodes.
QR Code barcode is a matrix (or two-dimensional) symbology designed by Denso Wave for the automotive industry. Now QR Code has grown popular due to its fast readability and large storage capacity, compared with linear barcodes.
For more QR Code information, please refer to .NET QR-Code Introduction.




Quick to Create QR Code using C#

The C# source code below explains how to quickly generate a QR Code image in C# class using BarcodeLib C# Barcode library.
  • Create a QRCode object
  • Enter the QR Code encoding text in property Data
  • Call method drawBarcode() to print QR Code to an image files in C# application
QRCode barcode = new QRCode();
barcode.Data = "https://www.barcodelib.com";
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-sample-image.png");





QR Code Text Data Encoding in C#

Here we will learn how to encode QR Code with various text, data formats using C# Barcode Generator SDK.

QR Code 2d barcode supports the following character sets and data format :
  • ASCII character (Uppercase, lowercase letters, digits 0-9, and special or control characters)
  • Unicode text
  • Binary data
  • Kanji characters


Encode ASCII characters in QR Code

ASCII character set includes 128 chars. 95 of them are printable characters, including Uppercase, lowercase letters, digits 0-9 and some special characters. 33 of them are control characters, which are not printable.

Encoding QR Code with printable ASCII chars is really simple. You can enter the ASCII chars to property Data.

QRCode barcode = new QRCode();
barcode.Data = "ABC-123-abc";
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-ascii-chars.png");



Encode ASCII control chars

To encode QR Code with ASCII control chars (non-printing chars), you need provide control char's ASCII integer value to property Data

  • Enable property ProcessTilde to true. The barcode library will process and convert the 3-digit integer behide the tilde char (~) to ASCII char.
  • Pass the ASCII chars to property Data. Each ASCII control chars will use it's ASCII integer value in 3-digits and add a tilde char (~) in beginning.
QRCode barcode = new QRCode();
barcode.ProcessTilde = true;
barcode.Data = "ABC-11-0~0130-22-abc";
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-ascii-control-chars.png");



Encode Unicode text in QR Code

Using BarcodeLib C# Barcode Generator library, you can directly enter the QR Code encoding Unicode text to property Data.
  • Enable property IsUnicodeData to true. The barcode library will automatically encode QR Code with the Unicode text in property Data
  • Enter the QR Code encoding Unicode text in property Data
QRCode barcode = new QRCode();
barcode.Data = "你好"; // hello in Chinese
barcode.IsUnicodeData = true;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-unicode-text.png");



Encode GS1 data message in QR Code

BarcodeLib C# QR Code Generator library supports GS1 QR Code generation in C# ASP.NET, WinForms application. To create GS1 compatible QR Codes, you need
  • Set property FNC1Mode with value QRCodeFNC1Mode.FirstPosition
  • Enter the GS1 application identifier and followed data text to property Data
QRCode barcode = new QRCode();
barcode.Data = "(17)050101";
barcode.FNC1Mode = QRCodeFNC1Mode.FirstPosition;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-gs1-data.png");





Print QR Code with specified image size using C#

QR Code is two-dimensional matrix barcode symbology that is made up of square modules arranged in an overall square pattern.
  • Set property ImageWidth with your specified QR Code size in pixel. The QR Code library will draw a sqaure QR Code using the size value of ImageWidth.
QRCode barcode = new QRCode();
barcode.Data = "https://www.barcodelib.com";
barcode.ImageWidth = 250;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-size.png");





Print QR Code with customized color, image options?



Create styled QR Code with logo image

You can also place a logo image on the center of the QR Code barcode using BarcodeLib C# QR Code Barcode Library.
  • In property LogoImage, specify the logo image file path
  • Specify the image rendering area in property LogoRenderSize
QRCode barcode = new QRCode();
barcode.Data = "https://www.barcodelib.com";
barcode.LogoImage = new System.Drawing.Bitmap(
       "C://BarcodeLib-files//barcodelib-logo.png");
barcode.LogoRenderSize = new System.Drawing.SizeF(300, 300);
barcode.ModuleColor = System.Drawing.Color.Blue;
barcode.UOM = UnitOfMeasure.INCH;
barcode.ResizeImage = true;
barcode.ImageWidth = 1.5f;
barcode.ImageHeight = 1.5f;
barcode.Resolution = 900;
barcode.ResizeImagePaddingTransparent = true;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-styled-logo.png");



Color Options

Using BarcodeLib C# Barcode component, you can easily change the QR Code default bar and space module's colors in C# application.
  • Set property ModuleColor to draw the QR Code bar module color in RGB.
  • Set property BackgroundColor to draw the QR Code space module color in RGB.
QRCode barcode = new QRCode();
barcode.Data = "https://www.barcodelib.com";
barcode.ModuleColor = Color.Red;
barcode.BackgroundColor = Color.LightSeaGreen;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-colors.png");



Print high quality QR Code image with high resolution

When you need create a high quality QR Code image for printing, you need choose a high image resolution during QR Code generation in C# application.
  • Enter the specified image resolution value (in PPI) to property Resolution.
QRCode barcode = new QRCode();
barcode.Data = "https://www.barcodelib.com";
barcode.UOM = UnitOfMeasure.INCH;
barcode.ImageWidth = 2;
barcode.Resolution = 900;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-image-resolution.png");



Print high quality QR Code to SVG, EPS vector images

BarcodeLib C# Barcode library supports create and print QR Code in raster and vector image formats.
  • Set property ImageFormat with the specified raster or vector image format. BLImageFormat.SVG for SVG image format, BLImageFormat.EPS for EPS image format.
QRCode barcode = new QRCode();
barcode.Data = "https://www.barcodelib.com";
barcode.ImageFormat = BLImageFormat.SVG;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-vector-image-svg.svg");
barcode.ImageFormat = BLImageFormat.EPS;
barcode.drawBarcode("C://BarcodeLib//csharp-qrcode-vector-image-eps.eps");

View QR Code SVG file in Chrome web browser

View QR Code EPS file in PDF reader




Generate QR-Code in C# ASP.NET Web Applications

With this C# QR Code generator, you can stream QR Code barcode images in ASP.NET using C#.NET in two ways.
  1. The simplest way for QR Code barcode generation is through BarcodeLib Buildin ASP.NET Barcode Application.
    • Unzip the downloaded evaluation package, and copy barcode folder and its contents to your IIS folder, eg. C:\inetpub.
    • Create a new virtual directory in your IIS, name it "barcode", and connect it to the above "barcode" folder in inetpub.
    • Restart IIS for a barcoding test.
    • To test your installation, open your web browser and navigate to:
      http://YourDomain:Port/barcode/qrcode.aspx?Data=12345678&LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12

      For further QR Code barcode setting, please view more web stream QR Code URL parameters here: .NET QR-Code Generator Property Settings.
    • To insert this QR Code image in your aspx or html page, simply pass the url to IMG tag or src value.
      For example:
      <img src=http://YourDomain:port/barcode/qrcode.aspx?Data=12345678&LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12 />
      This method will not generate any barcode images in your IIS server side.
  2. Another method is to create QR Code barcodes through ASP.NET web form controller.
    • Intall ASP.NET barcode controller to your barcoding project by adding reference.
    • Add barcode library to your Visual Studio toolbox.
    • Open your unzipped trial package, and copy files "qrcode.aspx", "qrcode.aspx.cs" to the aspx page, in which you will be generating QR Code images
    • Now you can drag QRCodeASPNET to your ASP.NET web site, and change QR code settings through properties window on the right or use above free C# source code.

    • Debug and you will see the QR Code barcode generated on your aspx pages.




How to Create QR-Code Barcodes in C# WinForms?

  1. Add reference to BarcodeLib.Barcode.WinForms.dll for your C# barcoding project.
  2. Add BarcodeLib.Barcode.WinForms.dll to your Visual Studio toolbox.
  3. Now please drag the QRCodeWinForm to your windows form or use above free C# source code, and a QR Code barcode is generated.




C# Barcode Library Supported Barcode Formats

C# 1D Barcode Generation:
C# 2D Barcode Generation:
C# Barcode DLL Generates 1D (Linear) Barcodes: Codabar, Code 11, Code 2 of 5, Code 39, Code 93, EAN-8, EAN-13, Interleaved 2 of 5, ITF-14 (UPC Shipping Container Symbol), Code 128, EAN 128/GS1 128, MSI Plessey, Intelligent Mail, Planet, Postnet, RM4SCC (British Royal Mail), UPC-A, UPC-E.
C# Barcode DLL Generates 2D (Matrix) Barcodes: Data Matrix, PDF 417, QR Code.