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.
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.
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
QRCodebarcode=newQRCode();
barcode.Data="你好"; // hello in Chinesebarcode.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
With the C# Barcode Generator library, you can directly create QR Codes encoded with byte array data in your C# application.
Set the QR Code data encoding mode to Byte mode for byte-level data encoding.
Enable the ProcessTilde property by setting its value to true. This setting allows the C# barcode library to recognize and process byte array data properly.
Call the method BarcodeUtils.ByteArrayToString() to convert your raw byte array into a formatted string.
Assign the converted string value to the Data property of the barcode generator.
Execute the barcode generation function to create a QR Code with your byte data embedded.
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.
View QR Code SVG file in Chrome web browser
View QR Code EPS file in PDF reader
How to create, customize QR Code with advanced features in C#?
Data encoding mode & data length
To encode QR Code data text with optimal efficiency, the QR Code generator library analyzes the input string, and it will select the most appropriate combination of data encoding modes automatically.
The C# QR Code Generator library provides 5 standard data mode options: Auto, Numeric, Alphanumeric, Byte, and Kanji.
QRCodeDataMode.Auto
The barcode library automatically selects the optimal data mode for your input content.
QRCodeDataMode.Numeric
Designed exclusively for numeric data (digits 0 – 9 only).
QRCodeDataMode.Alphanumeric
Supports mixed alphanumeric content.
Valid characters: digits 0 - 9, uppercase letters A - Z.
Also supports 9 special characters: space, $, %, *, +, -, ., /, :.
QRCodeDataMode.Byte
Used for general byte-level data encoding.
Default character set: ISO/IEC 8859-1.
Supports other custom-defined character sets as needed.
QRCodeDataMode.Kanji
Optimized for Kanji character encoding.
Each Kanji character is compressed to 13 bits for high-efficiency storage.
We recommend you to choose Auto mode (default), and the C# QR Code Generator SDK will automatically select the best encoding modes for your data.
Note: Selecting the correct data mode manually can improve QR Code density and scanning performance.
When working with a QR Code symbol of Version 40-L (Version 40, Low Error Correction Level), below is the maximum number of data characters it can encode:
Numeric data: Up to 7,089 characters
Alphanumeric data: Up to 4,296 characters
Byte data: Up to 2,953 characters
Kanji data: Up to 1,817 characters
Note
These limits are specific to Version 40-L (Low Error Correction).
Higher error correction levels (e.g., M, Q, H) will reduce the maximum number of encodable characters.
Always confirm your QR Code version and error correction level before encoding large datasets to avoid data truncation.
Error Correction Level (ECL)
QR Code uses four Reed-Solomon error correction levels. These levels are listed in ascending order of recovery capacity: L, M, Q, and H.
They help restore QR Code data if the code is damaged, dirty, or partially obscured.
QR Code supports a total of 40 standardized physical sizes, known as Versions. These versions are numbered sequentially from Version 1 up to Version 40.
When using the C# QR Code Generator library, you can configure the QR Code size by adjusting the Version property.
Note: Higher QR Code versions create larger symbols and can store more data. Lower versions generate smaller QR Codes with reduced data storage capacity.
When dealing with a large QR Code data message, you can split it into multiple parts and store them using the QR Code Structured Append mode.
This mode supports splitting a single data message into up to 16 separate QR Code symbols for easy storage and retrieval.
To implement the Structured Append feature using the C# QR Code Generator library, follow these property configurations:
EnableStructuredAppend
Set this property's value to true. This enables the Structured Append mode, allowing the library to handle split data across multiple QR Codes.
StructuredAppendCount
This property specifies the total number of QR Code symbols that will store the complete data message.
Ensure the value matches the exact number of symbols you plan to generate (maximum 16).
StructuredAppendIndex
Use this property to define the position of the current QR Code symbol in the sequence.
Note: The first symbol in the sequence must be set to index 0 (not 1).
StructuredAppendParity
Set property with a random unique integer. All QR Codes to store the same data message should have the same parity value.
Notes:
Ensure all symbols in the sequence have the same SymbolCount value; mismatched values will prevent successful data merging.
The maximum number of symbols per data message is 16. Exceeding this limit will result in encoding errors.
The QR Code FNC1 mode indicator is used to mark encoded data that complies with the GS1 Application Identifiers standard.
This indicator ensures scanners recognize the QR Code as GS1-formatted data.
To generate GS1 QR Code, you must following the configuration below
FNC1Mode
Assign the value QRCodeFNC1Mode.FirstPosition to this property. This setting enables FNC1 mode for GS1 standard-compliant QR Code encoding.
With this C# QR Code generator, you can stream QR Code barcode images in ASP.NET using C#.NET in two ways.
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.
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?
Add reference to BarcodeLib.Barcode.WinForms.dll for your C# barcoding project.
Add BarcodeLib.Barcode.WinForms.dll to your Visual Studio toolbox.
Now please drag the QRCodeWinForm to your windows form or use above free C# source code, and a QR Code barcode is generated.