.NET Barcode Generator Guide

Bar Codes Generation for .NET, ASP.NET, C#, VB.NET development

 

  • Easy & Simpleto generate barcodes in ASP.NET, Windows, Reporting Service & Crystal Reports
  • Complete developer guide for ASP.NET, C#, VB.NET professionals
  • Generate high quality JPEG, GIF & PNG barcode images
  • 100% build in managed C#
  • Mature .net barcode component since 2003
  • Compatible with latest barcode symbology standards
  • Create linear barcodes, including Code39, Code128, GS1-128, Interleaved 2 of 5, EAN / UPC
  • Create 2d barcodes, including Data Matrix, PDF-417, & QR-Code
  • Royalty-free and perpetual developer license



This document is a guide of what & how you can do with .NET Barcode Generator component in your various .NET development environments.



Quick access:      Overview   |   for .NET Class   |   for ASP.NET   |   for WinForms   |   for Reporting   |   Barcode Properties

 

Barcode for .NET Trial Package Overview

Barcode for .NET is a mature & reliable .NET barcode generator component for linear & 2d barcode generation in .NET class, ASP.NET, Windows Forms, Console Application, Reporting Service 2005 & Crystal Reports for .NET.

Barcode for .NET trial package includes:

  • BarcodeLib.Barcode.dll, .net library includes all supporting barcode types and functions for barcode generation in .net class, ASP.NET, Windows Forms, Crystal Reports for .NET
  • BarcodeLib.Barcode.ReportingService.dll, .net library for Reporting Service 2005
  • BarcodeDemo.exe, a barcode demo application
  • DeveloperGuide.html, guide for developers to use this component
  • /barcode, contains Barcode for .NET Buildin Barcode Generation web application for developers.
  • /ReportingData, contains sample database for barcode generation in .net reporting.
  • /BarcodeDemoSRC, complete source code for the demo application "BarcodeDemo.exe".
  • LicenseAgreement.txt, Barcode for .NET End-User License Agreement

 

 

How to Generate Barcodes in .NET Class or .NET Console application?

Install: Add Reference BarcodeLib.Barcode.dll to your project. Do not copy the dll to the bin directory, Visual Studio will do so, during project compilation time.

Implementation: The following C#.net code illustrates how to generate a 1d (linear) barcode in a C# class

	BarcodeLib.Barcode.Linear.Linear barcode = new BarcodeLib.Barcode.Linear.Linear();
	
	barcode.Type = BarcodeType.CODE39;
	
	barcode.Data = "CODE39-123456789012";
	
	barcode.N = 3;
	
	barcode.AddCheckSum = true;
	
	barcode.UOM = UnitOfMeasure.Pixel;
	barcode.BarWidth = 1;
	barcode.BarHeight = 80;
	barcode.LeftMargin = 10;
	barcode.TopMargin = 10;
	
	barcode.Format = ImageFormat.Png;
	
	// more barcode settings here
	                        
	// save barcode image into your system
	barcode.drawBarcode("c:/barcode.png");
	
	// generate barcode & output to byte array
	byte[] barcodeInBytes = barcode.drawBarcodeAsBytes();
	
	// generate barcode to Graphics object
	Graphics graphics = ...
	barcode.drawBarcode(graphics);
	
	// 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.

  1. 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=CODE39&Data=12345678
    • 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=CODE39&Data=12345678" />

      or for Data Matrix
      <img src="http://YourDomain:port/barcode/datamatrix.aspx?Data=12345678" />

      or for PDF417
      <img src="http://YourDomain:port/barcode/pdf417.aspx?Data=12345678" />

      or for QRCode
      <img src="http://YourDomain:port/barcode/qrcode.aspx?Data=12345678" />


      Using this method, it will not generate any barcode images in your IIS server side.


  2. The second method is to generate barcode images through ASP.NET Web Form controller

    1. Install .NET Barcode Controller to your ASP.NET project.
      1. Add Reference BarcodeLib.Barcode.dllto your project. Do not copy the dll to the bin directory, Visual Studio will do so, during project compilation time.
      2. Copy linear.aspx file to your web application.
    2. Add barcode library to your Visual Studio Toolbox.
      1. Open Toolbox in Visual Studio. Click menu View, and check submenu Toolbox.
      2. Right click Toolbox, click menu Choose Items...
      3. Goto .NET Framework Componentstab.
      4. If no BarcodeLib component found, click Browse... button and select BarcodeLib.Barcode.dllfile.
      5. Then sort "Namespace" column, you will find 8 components from BarcodeLib.Barcode.
      6. Check component DataMatrixWebForm, and its namespace is BarcodeLib.Barcode.DataMatrix
      7. Check component LinearWebForm, and its namespace is BarcodeLib.Barcode.Linear
      8. Check component PDF417WebForm, and its namespace is BarcodeLib.Barcode.PDF417
      9. Check component QRCodeWebForm, and its namespace is BarcodeLib.Barcode.QRCode

        do not select WinForm controls, which are for Windows Forms.
      10. Click "OK" button, you will find four components under "General": LinearWebForm, DataMatrixWebForm, PDF417WebForm, QRCodeWebForm.
    3. Go to "barcode" folder in the trial package, copy files "linear.aspx", "datamatrix.aspx", "pdf417.aspx", "qrcode.aspx" to the same folder as your aspx page, which will generate barcodes.
    4. You can drag LinearWebFormon your aspx page, change barcode setting through properties window.
    5. Run the project, you will find barcode images generated in your aspx pages.

 

 

How to Generate Barcodes in .NET Windows Forms application?

  1. Add Reference BarcodeLib.Barcode.dllto your project. Do not copy the dll to the bin directory, Visual Studio will do so, during project compilation time.
    1. In your .NET windows project, right click mouse over Refereces in your Solution Explorer window. Then click menu "Add Reference ...".
    2. Add BarcodeLib.Barcode.dll to your project.
  2. Add barcode library to your Visual Studio Toolbox.
    1. Open Toolbox in Visual Studio. Click menu View, and check submenu Toolbox.
    2. Right click Toolbox, click menu Choose Items...
    3. Goto .NET Framework Componentstab.
    4. If no BarcodeLib component found, click Browse... button and select BarcodeLib.Barcode.dllfile.
    5. Then sort "Namespace" column, you will find 8 components from BarcodeLib.Barcode.
    6. Check component DataMatrixWinForm, and its namespace is BarcodeLib.Barcode.DataMatrix
    7. Check component LinearWinForm, and its namespace is BarcodeLib.Barcode.Linear
    8. Check component PDF417WinForm, and its namespace is BarcodeLib.Barcode.PDF417
    9. Check component QRCodeWinForm, and its namespace is BarcodeLib.Barcode.QRCode

      do not select WebForm controls, which are for ASP.NET Web Forms.
    10. Click "OK" button, you will find four components under "Common Controls": LinearWinForm, DataMatrixWinForm, PDF417WinForm, QRCodeWinForm.
  3. Now you can see the component displayed on Toolbox. You can drag LinearWinForm on your form, change barcode setting through properties widnow.

 

 

How to Generate Barcodes in .NET reporting projects?

 

 

Barcode for .NET Each Each Barcode Symbology Property Settings

1D (Linear) Barcode Types/Symbologies

2D (Matrix) Barcode Types/Symbologies

 

Barcode Generating in various .NET environments

 

posted @ 2012-04-02 15:12  Net-Spider  阅读(806)  评论(0)    收藏  举报