Crystal Reports Barcode How-Tos
PM > Install-Package BarcodeLib.Crystal.Reports


Home > .NET Crystal Reports Barcode > Crystal Reports Barcode Generation Guide > Crystal Reports QR-Code Generator DLL

Crystal Reports QR Code Generator Library

How to Generate 2D QR-Code Barcodes in Crystal Reports for .NET
  • Easy to create barcodes in Crystal Reports without using barcode fonts or third party tools
  • Developed in Visual C# with full integration for .NET 2.0 and later version
  • Simple to print QR Code barcodes using Crystal Report in Windows applications and ASP.NET web applications
  • Programmatically create, generate QR Code 2D barcodes with C# and VB.NET
  • Programmatically create QR-Codes in ASP.NET with C#, VB.NET Class Library
  • Make multiple QR Codes images in Crystal Report within a few steps
  • Flexible barcode settings available as specified in standard
  • Complete barcode settings to adjust various QR Code barcode parameters
The QR Code barcode generation control for Crystal Reports is a professional and robust .NET component designed for integration with Visual Studio 2005, 2008, 2010, and later versions. It enables dynamic generation of QR Code symbols within Crystal Reports, suitable for listing and reporting scenarios.


This guide delivers a structured, step-by-step approach to creating and printing QR Code (Quick Response Code) images into Crystal Reports for .NET, supporting both ASP.NET and Windows Forms projects.

Using the Barcode Generator for Crystal Reports .NET library, you can embed QR Codes directly into .rpt files (Crystal Reports template files) for display in CrystalReportViewer (WinForms, WPF, or ASP.NET viewer control) or exported report formats.


.NET Crystal Reports QR Code Barcode Introduction
QR-Code is also known as Quick Response Code, Denso Barcode, QRCode, JIS X 0510, ISO/IEC 18004.
Compatibility: Barcode for Crystal Reports control / dll is compatible with ISO/IEC 18004 (Second Edition 2006-09-01) bar code symbology specification.
For more QR Code information, please refer to .NET QR-Code Introduction.


How to Generate QR Code barcode in Crystal Reports with ASP.NET Website
  1. Create a new ASP.NET website.
    • Create a new web site project using "ASP.NET Crystal Reports Web Site" as template, named "BarcodeforCrystalReportsWebSite".
  2. Add a Crystal Report item to the project.
    • Add a new item (Crystal Report), named "CustomerReport.rpt" to the project. view image
    • Select Expert as "Mail Label". Click "OK" button. view image
    • In "Mailing Labels Report Creation Wizard", click "Create New Connection", and expand "ADO.NET". view image
    • In "ADO.NET" form, select "CustomerDataSet.xsd" file in your downloaded package, and click "Finish" button. view image
    • In "Mailing Labels Report Creation Wizard", add table "Customer" under "ADO.NET", to selected table. And click "Next" button. view image
    • Add all three fields "ID", "CustomerId", "CustomerName", to "Fields to Display:". Click "Next". view image
    • Select default label "Return Address (Avery 5267)", and click "Finish" button.
    • Now you can view the report template, and find that field "Barcode" not in the report template. view image
    • Re-arrange the report template. view image
    • Drag field "Barcode" to the report template. Right click "Barcode" object and select "Format Object" menu. view image
    • In "Format Editor" form, check "Can Grow" property. view image
  3. Add Crystal Report Viewer to the Default.aspx.
    • Add a reference to BarcodeLib.Barcode.CrystalReports.dll.
    • Add the following code to the Default.aspx.cs file.
     using System.Data.OleDb;
using System.Drawing.Imaging;
using BarcodeLib.Barcode.CrystalReports;
using BarcodeLib.Barcode;


protected void Page_Load(object sender, EventArgs e)
{
// Create the database connection. Please change to correct data file (BarcodeDemoData.mdb) path.
OleDbConnection aConnection = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:/BarcodeLib_NETBarcode_Trial/ReportingData/BarcodeDemoData.mdb"
);
aConnection.Open();

OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM Customer", aConnection);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);

// Add the Barcode column to the DataSet
ds.Tables[0].Columns.Add(new DataColumn("Barcode", typeof(byte[])));

// Use QRCodeCrystal for QR Code
QRCodeCrystal barcode = new QRCodeCrystal();

// Barcode settings
barcode.ModuleSize = 3;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

foreach (DataRow dr in ds.Tables[0].Rows)
{
barcode.Data = (int)dr["CustomerId"] + "";
byte[] imageData = barcode.drawBarcodeAsBytes();
dr["Barcode"] = imageData;
}

CrystalReportSource1.ReportDocument.Load(Server.MapPath("CustomerReport.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables[0]);
CrystalReportSource1.DataBind();

}
4. Run the project.


How to Create QR Code Bar Code in Crystal Reports with .NET Windows Forms
  1. Create a new Windows Application Project.
    • Create a new project using "Crystal Reports Application" as template, named "BarcodeforCrystalReports".
  2. Add a Crystal Report item to the project. View How to Add Crystal Report to Project
  3. Add Crystal Report Viewer to the window form.
    • Resize "Form1", and add "CrystalReportViewer" to the form, with the default setting unchanged. view image
    • Add a reference to BarcodeLib.Barcode.CrystalReports.dll.
    • Add the following code to the Form1.cs file.
     using System.Data.OleDb;
using System.Drawing.Imaging;
using BarcodeLib.Barcode.CrystalReports;
using BarcodeLib.Barcode;


private void Form1_Load(object sender, EventArgs e)
{
// Create the database connection. Please change to correct data file (BarcodeDemoData.mdb) path.
OleDbConnection aConnection = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:/BarcodeLib_NETBarcode_Trial/ReportingData/BarcodeDemoData.mdb"
);aConnection.Open();

OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM Customer", aConnection);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);

// Add the Barcode column to the DataSet
ds.Tables[0].Columns.Add(new DataColumn("Barcode", typeof(byte[])));

// Use QRCodeCrystal for QR Code
QRCodeCrystal barcode = new QRCodeCrystal();

// Barcode settings
barcode.ModuleSize = 3;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

foreach (DataRow dr in ds.Tables[0].Rows)
{
barcode.Data = (int)dr["CustomerId"] + "";
byte[] imageData = barcode.drawBarcodeAsBytes();
dr["Barcode"] = imageData;
}

CustomerReport rpt = new CustomerReport();
rpt.SetDataSource(ds);

this.crystalReportViewer1.ReportSource = rpt;

//close the connection Its important.
aConnection.Close();

}
4. Run the project.
How to Print QR Code Barcodes in Crystal Reports Using C#, VB.NET
BarcodeLib.com also provides detailed guide for users to create barcodes in Crystal Report using C# / VB.NET (Visual Basic). Please go to the links below for detailed tutorials with C# or VB.NET sample code.


QR Code Text Encoding in Crystal Reports



QR Code Encoding Character Sets for Crystal Reports

  • Numbers (digits 0–9)
  • ASCII characters (plain text)
  • Unicode text. For multilingual reports (Arabic, Greek, Thai) in global deployments
  • Byte data (default: ISO/IEC 8859-1). Encoding byte arrays stored in ADO.NET DataSet
  • Kanji characters (13-bit compression). Optimized for Japanese locale reports


QR Code Data Mode for Crystal Reports

The Crystal Reports for .NET Barcode library automatically analyzes the encoding data and selects the appropriate QR Code data mode. To manually customize the data mode encoding, use the following C# code:
  • QRCodeDataMode.Auto (Default): The library chooses the optimal combination of data modes based on the encoding data.
  • QRCodeDataMode.Numeric: Digits 0 - 9 only.
  • QRCodeDataMode.AlphaNumeric: 0 - 9, A - Z, and special characters.
  • QRCodeDataMode.Byte: Byte data (ISO/IEC 8859-1).
  • QRCodeDataMode.Kanji: Kanji characters (13-bit).


Maximum Data Length for Crystal Reports QR Codes

The QR Code standard specifies forty sizes, referred to as Version 1 through Version 40. Version 40-L QR Codes, the largest standard size, support the following limits to avoid truncation in Crystal Reports:
  • Numeric data: 7,089 characters
  • Alphanumeric data: 4,296 characters
  • Byte data: 2,953 characters
  • Kanji data: 1,817 characters
Note: Exceeding these limits triggers QR Code encoding errors. The Structured Append mode, covered later, can be used for large text messages.


Print QR Code with Diverse Text Formats in Crystal Reports

QR Code is a 2D barcode symbology that supports various text string formats defined by industry standards, such as the GS1 Specification. The following sections explain how to print QR Codes with diverse text formats in Crystal Reports using C#.


Encode ASCII Non-Printing Characters

ASCII control characters, such as carriage return (CR), require special encoding for structured data in Crystal Reports formula field output.
  • Set ProcessTilde to true to enable the tilde (~) as an escape character.
  • In the Data property, non-printable characters are converted to the ~ddd format, where ddd is the three-digit ASCII value.



Encode Unicode Text (Multilingual Reports)

QR Codes do not natively support Unicode, but two methods enable multilingual Crystal Reports:
  • Set EncodeUnicodeText to true to print QR Codes with Unicode text encoding in Crystal Reports.
  • Enter the Unicode text string in the Data property.



Generate GS1-Compliant QR Codes in Reports

GS1 QR Codes integrate industry-standard data, such as expiration dates and batch numbers, into Crystal Reports for supply chain and retail use cases.
  • Set FNC1 = FNC1.FNC1_1ST_POS to enable GS1 formatting.
  • In the Data property, include AI codes in parentheses followed by the data.



Customizing QR Code Dimensions & Layout for Crystal Reports

Optimize QR Code dimensions for Crystal Reports image controls to avoid distortion in printed or exported reports. Use BarcodeWidth; QR Codes are square, so the width defines both dimensions. Add the following C# code to the Crystal Reports for .NET project:
  • Determine the QR Code printing size in the .rpt file (matches BarcodeWidth).
  • Use UOM to select the preferred unit of measure (inch or cm).
  • Specify the QR Code rendering side with BarcodeWidth.



Configure QR Code Quiet Zones

Quiet zones, or blank space, ensure scannability. Set margins on QR Code images in Crystal Reports.

The QR Code standard requires a quiet zone of 10X, where X is the QR Code module size. Insufficient quiet zones may cause scan errors in printed reports; test physical prints before deployment.


Customizing QR Code Appearance for Crystal Reports



Configure Colors

Customize QR Code colors to match brand guidelines, such as Crystal Reports Report Header branding.
  • ForeColor: QR Code modules color, typically black.
  • BackColor: QR Code background color, typically white.



Advanced Image Options

  • High-Resolution QR Codes: Optimize for printed reports, critical for Crystal Reports printing functionality.
  • Transparent Background: Seamless integration with Crystal Reports Details section backgrounds.


Advanced QR Code Options for ASP.NET/WinForms Crystal Reports

The following advanced customization parameters are available for QR Code. It is recommended to use the preset values of the library. If modifications are required to meet specific requirements, refer to the C# code examples below.


Error Correction Mode

Reed-Solomon error correction ensures QR Codes remain scannable, which is critical for printed reports. Configure the error correction level (ECL) to match the use case:
  • QRCodeECL.L: 7% (default)
  • QRCodeECL.M: 15%
  • QRCodeECL.Q: 25%
  • QRCodeECL.H: 30%


QR Code Version

QR Codes have 40 versions (sizes) to accommodate varying data volumes in Crystal Reports. Higher versions (e.g., V40) require larger PictureBox controls in Crystal Reports.


Structured Append Mode

Split a large text message across up to 16 QR Codes, which is useful when the data exceeds the capacity of a single QR Code.



FNC1 First Position (GS1)

Enable FNC1.FNC1_1ST_POS for GS1-compliant Crystal Reports in supply chain and retail scenarios.



Summary

This guide has provided a comprehensive walkthrough for generating and customizing QR Code barcodes in Crystal Reports using the BarcodeLib Barcode Generator for Crystal Reports for .NET library.
  • Print QR Codes in Reports: Generate QR Codes in C# (or VB.NET) and bind them to Crystal Reports for .NET using ReportDocument, CrystalReportViewer, and .rpt file templates. This approach is compatible with ASP.NET Web Forms, WinForms, and WPF (via WindowsFormsHost).
  • Handle Diverse Text Formats: Utilize automatic or manual data modes to support ASCII, Unicode, and GS1-compliant data. Non-printable characters are processed using tilde encoding, ensuring accurate binding to Crystal Reports formula and parameter fields.
  • Optimize Appearance and Layout: Adjust dimensions, quiet zones, colors, and resolution to align with Crystal Reports layout requirements across headers, footers, and details sections. Advanced features such as Structured Append and error correction levels provide flexibility for enterprise reporting needs.
Crystal Reports Barcode Generator Control Supported Symbologies
Linear (1D) Barcodes:
Matrix(2D) Barcodes: