How to install Crystal Reports Barcode library in C#.NET project?
Install through NuGet
For .NET Framework 4.7.1 or later (Class library, Console, Windows Forms, WPF) apps on Windows
PM > Install-Package OnBarcode.Crystal.Reports
Download & install dll
OnBarcode Crystal Reports for .NET Barcode Generator library trial version is free to download. You can manually download it here :
Download C# Barcode Generator SDK trial version
To install the downloaded Crystal Reports barcode generator dll
To install the downloaded Crystal Reports barcode generator dll
- Add OnBarcode.Barcode.CrystalReports.dll from folder "{downloaded package}/dll/Report-CrystalReports/" to .NET project reference.
- You need manually add nuget package
System.Drawing.Commonfrom "NuGet Package Manager" to .NET Core project reference.
Upgrade the dll
To upgrade the dll to latest version or upgrade the trial version dll to licensed one, you need
- Remove the installed dll or nuget package from the project. (you need clean the project cached data also)
- Add the new dll OnBarcode.Barcode.CrystalReports.dll to the .net project reference
How to print barcodes with specified width & height in Crystal Reports using C#?
Here we will explain how to print barcode with specified image width and height in Crystal Reports report files in C# ASP.NET, WinForms applications.
Here we will use our prepared WinForms tutorial to demonstrate. You can view the detailed tutorial here: How to create, print barcode in Crystal Reports in C# Windows Forms application?
In the following content, we will print Code 128 barcodes with 5-inch width and 2-inch height in Crystal Reports in C# .NET projects.
Here we will use our prepared WinForms tutorial to demonstrate. You can view the detailed tutorial here: How to create, print barcode in Crystal Reports in C# Windows Forms application?
In the following content, we will print Code 128 barcodes with 5-inch width and 2-inch height in Crystal Reports in C# .NET projects.
1. Customize barcode resolution and size settings
Open file
Add the following C# codes in the method
Form1.cs in the Visual Studio
Add the following C# codes in the method
Form1_Load
- Change the barcode unit of measure to
INCH - Set the barcode image resolution to 600 ppi. High resolution image will improve the printed barcode quality.
- Set the barcode image width to 5 inches, and height to 2 inches.
linear.UOM = UnitOfMeasure.INCH; linear.Resolution = 600; linear.BarcodeWidth = 5; linear.BarcodeHeight = 2;
2. Update the barcode object in the report properties
Open file
Select the barcode object in the report, and change the following properties.
Right click barcode object, and choose Format Object. Go to tab Picture.
Make sure the size settings are correct.
CrystalReport1.rpt in Visual Studio
Select the barcode object in the report, and change the following properties.
- Set
XScalingto 5 - Set
YScalingto 2
Right click barcode object, and choose Format Object. Go to tab Picture.
Make sure the size settings are correct.
3. View, measure the barcode in Crystal Reports
Run the Windows Forms project, and view the barcodes printed in the report.
View the rendered barcodes in PDF exported from Crystal Reports.
View the rendered barcodes in PDF exported from Crystal Reports.
How to Generate Barcode Images in .NET Crystal Reports
The following tutorial is for old version of Crystal Reports Barcode Generator library. To learn the latest version of Crystal Reports Barcode library, please navigate to
- In our demo dataset "BarcodeDemoData.mdb", there is a table "Customer", with three columns inside: "ID", "CustomerId", "CustomerName".
- There is a CustomerDataSet.xsd file for "BarcodeDemoData.mdb", which defines all above three columns in Customer table, also define one extra column named "Barcode", with data type "xs:base64Binary".
- In the following example, we will show you how to display all three column data and also with the extra barcode column which displays Code 128 barcode with "CustomerId" value encoded.
- Create a new .NET project with "Crystal Reports Application" as template. Name the project as "CrystalReportsBarcode".

- Create a new report "Using the Report Wizard", and choose "Standard", and click "OK" button.
- In "Data" form, expand "Create New Connection", and expand "ADO.NET".

- In "Connection" form, select the "CustomerDataSet.xsd" in your downloaded sample dataset package. Then click "Finish" button.

- In "Data" form, and add table "Customer". Then click "Next".

- In "Fields" form, add all three columns in the table "Customer". Click "Finish".

- In CrystalReport1.rpt, add field "Barcode" to the report Section 3 (Details).

- In your .NET project solution explorer, add "OnBarcode.Barcode.WinForms.dll" to your project reference.
- Open your Form1.cs in Design view, double click the form, enter Form1.cs.

- Copy the following C# code into the method Form1_Load.
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Demo/BarcodeDemoData.mdb");
aConnection.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter("select * from Customer", aConnection);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
//add a new column named "Barcode" to the DataSet, the new column data type is byte[]
ds.Tables[0].Columns.Add(new DataColumn("Barcode", typeof(byte[])));
Linear barcode = new Linear();
barcode.Type = BarcodeType.CODE128;
foreach (DataRow dr in ds.Tables[0].Rows)
{
barcode.Data = (int)dr["CustomerId"] + "";
byte[] imageData = barcode.drawBarcodeAsBytes();
dr["Barcode"] = imageData;
}
CrystalReport1 rpt = new CrystalReport1();
rpt.SetDataSource(ds);
this.crystalReportViewer1.ReportSource = rpt;
aConnection.Close();
}
11. Run the report.
Barcode Types Supported By .NET Crystal Reports Barcode Control
Barcode Control for Crystal Report - Bar Code Type Generation
- Crystal Reports 1D / Linear Barcodes:
- Crystal Reports 2D / Matrix Barcodes: Data Matrix, PDF-417, QR Code, Micro PDF-417, Micro QR Code
