Home > .NET Barcode
> .NET Barcode Generation Guide - How to create 1d & 2d barcodes in .NET application using free C#, VB.NET demo codes
.NET Barcode Generator Guide
Bar Codes Generation for .NET, ASP.NET, C#, VB.NET development
Easy & Simple to generate barcodes in ASP.NET, Windows, Reporting Service, Crystal Reports & RDLC Reports
Provide detailed and complete developer guide for ASP.NET, C#, VB.NET professionals
High print quality 1D and 2D barcode images are easy to be generated with mature APIs
Available to be used in both C# and VB.NET programming environments
Put into use in 2003, regarded as effective and reliable .net barcode component library by users
Well developed under the requirements of the latest barcode symbology specifications
Create linear barcodes, including Code39, Code128, GS1-128, Interleaved 2 of 5, EAN / UPC
Create 2d barcodes, including Data Matrix, PDF-417, & QR-Code barcode images
Obtain royalty-free and perpetual .NET Barcode DLL Suite developer license at reasonable price
This document is a guide of what & how you can do with .NET Barcode Generator components in your various .NET Framework development environments.
Barcode for .NET Free Trial Package Overview
Barcode for .NET is a suite of mature & reliable .NET barcode generator components for linear & 2d barcode generation in .NET class, ASP.NET, Windows Forms, Console Application, Reporting Service 2005/2008, Crystal Reports for .NET and RDLC Local Reports for .NET.
Free Barcode for .NET trial package includes:
BarcodeLib.Barcode.ASP.NET.dll, .net library for barcode generation in ASP.NET class, ASP.NET Web, IIS applicaitons.
BarcodeLib.Barcode.WinForms.dll, .net library for barcode generation in .NET class, .NET Windows Forms applicaitons.
BarcodeLib.Barcode.ReportingService05.dll & BarcodeLib.Barcode.ReportingService05CRI.dll, .net library for barcode generation in Reporting Service 2005 applicaitons.
BarcodeLib.Barcode.ReportingService08.dll & BarcodeLib.Barcode.ReportingService08CRI.dll, .net library for barcode generation in Reporting Service 2008 applicaitons.
BarcodeLib.Barcode.CrystalReports.dll, .net library for barcode generation in Crystal Reports applications.
BarcodeLib.Barcode.RDLCReports.dll, .net library for barcode generation in Client RDLC Reports applications.
DeveloperGuide.html, guide for developers to use these .net bar coding components.
/barcode, contains Barcode for .NET Buildin Barcode Generation web application for developers.
/ReportingData, contains sample database for barcode generation in .net reporting.
/BarcodeDemoSRC, contains BarcodeDemo.exe (a barcode demo application) and BarcodeLib.Barcode.WinForms.dll for the demo application "BarcodeDemo.exe".
LicenseAgreement.pdf, Barcode for .NET End-User License Agreement.
How to Generate Barcodes in .NET Class or .NET Console Application?
Install .NET Barcode DLL
Add Reference BarcodeLib.Barcode.ASP.NET.dll or BarcodeLib.Barcode.WinForms.dll to your project. There's no need to copy barcoding dll to your project bin folder because Visual Studio will do it for you during project compilation time.
Implementation
The following C#.net code illustrates how to generate a 1d (linear) barcode using a C# class.
BarcodeLib.Barcode.Linear barcode = new BarcodeLib.Barcode.Linear();
// generate barcode and output to Bitmap object Bitmap barcodeInBitmap = barcode.drawBarcode();
// generate barcode and output to HttpResponse object HttpResponse response = ...; barcode.drawBarcode(response);
// generate barcode and output to Stream object Stream stream = ...; barcode.drawBarcode(stream);
How to Generate Barcodes in ASP.NET Web Sites?
There are two methods to create barcode images in your ASP.NET web applications.
The Simplest way is to stream barcode image using our Buildin ASP.NET Barcode Application.
Under downloaded trial package, copy barcode folder to your IIS folder, e.g. C:\Inetpub.
Create a new virtual directory in IIS, named barcode, and link to the above "barcode" folder.
Restart IIS.
To test your installation, open your web browser and navigate to: http://YourDomain:Port/barcode/linear.aspx?Type=7&Data=CODE39-123456789012
To create barcode image in your aspx or html page, you need pass the url to IMG tag src value. For linear barcode: <img src="http://YourDomain:port/barcode/linear.aspx?Type=7&Data=CODE39-123456789012" /> or for Data Matrix barcode <img src="http://YourDomain:port/barcode/datamatrix.aspx?Data=BarcodeLib12345678&ModuleSize=4&LeftMargin=8&RightMargin=8&TopMargin=8&BottomMargin=8" /> or for PDF417 barcode <img src="http://YourDomain:port/barcode/pdf417.aspx?Data=123456789&ModuleSize=3&LeftMargin=6&RightMargin=6&TopMargin=6&BottomMargin=6" /> or for QRCode barcode <img src="http://YourDomain:port/barcode/qrcode.aspx?Data=0123456789&ModuleSize=3&LeftMargin=12&RightMargin=12&TopMargin=12&BottomMargin=12" /> This method will not generate any barcode images in your IIS server side.
The second method is to generate barcode images through ASP.NET Web Form controller.
Install ASP.NET Barcode Library Controller to your ASP.NET project.
Add Reference BarcodeLib.Barcode.ASP.NET.dll to your project. There's no need to copy barcoding dll to your project bin folder because Visual Studio will do it for you during project compilation time.
Add ASP.NET barcode library dll to your Visual Studio Toolbox.
Open Toolbox in Visual Studio. Click menu View, and check submenu Toolbox.
Right click Toolbox, and 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.
Check component DataMatrixASPNET, and its namespace is BarcodeLib.Barcode.
Check component PDF417ASPNET, and its namespace is BarcodeLib.Barcode.
Check component QRCodeASPNET, and its namespace is BarcodeLib.Barcode.
Click "OK" button, you will find four components under "General": LinearASPNET, DataMatrixASPNET, PDF417ASPNET, QRCodeASPNET.
Go to "barcode" folder in the trial package, and then copy files "linear.aspx", "linear.aspx.cs", "datamatrix.aspx", "datamatrix.aspx.cs", "pdf417.aspx", "pdf417.aspx.cs", "qrcode.aspx", "qrcode.aspx.cs" to the same folder as your aspx page, which will generate barcodes.
You can drag LinearASPNET on your aspx page, and change barcode setting through properties window.
Run the project. You will find barcode images generated in your aspx pages.
How to Generate Barcodes in .NET Windows Forms Application?
Add Reference BarcodeLib.Barcode.WinForms.dll to your project. There's no need to copy barcoding dll to your project bin folder because Visual Studio will do it for you 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.WinForms.dll to your project.
Add .net winforms barcode library dll to your Visual Studio Toolbox.
Open Toolbox in Visual Studio. Click menu View, and check submenu Toolbox.
Right click Toolbox, and click menu Choose Items....
Goto .NET Framework Components tab.
If no BarcodeLib component found, click Browse... button and select BarcodeLib.Barcode.WinForms.dll file.
Then sort "Namespace" column. You will find 4 components from BarcodeLib.Barcode.
Check component LinearWinForm, and its namespace is BarcodeLib.Barcode.
Check component DataMatrixWinForm, and its namespace is BarcodeLib.Barcode.
Check component PDF417WinForm, and its namespace is BarcodeLib.Barcode.
Check component QRCodeWinForm, and its namespace is BarcodeLib.Barcode.
Click "OK" button, and you will find four components under "Common Controls": LinearWinForm, DataMatrixWinForm, PDF417WinForm, QRCodeWinForm.
Now you can see the component displayed on Toolbox. Then, you can drag LinearWinForm on your form and change barcode setting through properties window.
How to Generate Barcodes in .NET Reporting Projects?