Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET Barcode > C# Barcode Generation Guide > C# Code 128 Generator Library for .NET
Download Barcode for .NET Suite Trial

Code 128 C# Generator DLL for .NET

How to Encode, Create Code 128 Barcode Images in .NET Framework Using C#
  • Adopt rich Visual C# linear barcoding functions of Code 128 .NET Barcode Control
  • Easy to install C# Code 128 Barcode Generator DLL into Visual Studio .NET applications
  • Strong named, digitally signed and time-stamped assemblies designed in C# managed code
  • Generate dynamic Code 128 barcodes into Microsoft .NET Framework Applications, like Windows Forms and ASP.NET Web Form
  • Generate and draw linear barcode Code 128 images on .NET Crystal Reports, Reporting Services and Client RDLC Reports
  • Code 128 barcode images may be created or saved as graphic images without any use of barcode tool
  • Create ISO/IEC compatible Code 128 barcodes with advanced print quality on low / high-resolution printers
  • Support over 20 linear & 2d barcode generation, like Codabar, Code 39, GS1-128, QR Code, Data Matrix, etc
C# Code 128 Barcode Type Introduction
Code-128 is commenly referred as ANSI/AIM 128, ANSI/AIM Code 128, USS Code 128, Uniform Symbology Specification Code 128, Code 128 Code Set A, Code 128 Code Set B, Code 128 Code Set C, Code 128A, Code 128B, Code 128C.
ISO/IEC Specification Compatibility: In accordance with ISO/IEC 15417 (Second edition 2007-06-01)
Code 128 is a very effective, high-density symbology which permits the encoding of alphanumeric data. The symbology includes a checksum digit for verification, and the bar code may also be verified character-by-character verifying the parity of each data byte. This symbology has been widely implemented in many applications where a relatively large amount of data must be encoded in a relatively small amount of space. It's specific structure also allows numeric data to be encoded at, effectively, double-density.
Three Code Sets of Code 128 barcode
  • Code Set A (or Chars Set A) contains all of the standard upper case U.S. alphanumeric keyboard characters and punctuation characters together with the control characters, (i.e. characters with ASCII values from 0 to 95 inclusive), and seven special characters.
  • Code Set B (or Chars Set B) contains all of the standard upper case alphanumeric keyboard characters and punctuation characters together with the lower case alphabetic characters (i.e. characters with ASCII values from 32 to 127 inclusive), and seven special characters.
  • Code Set C (or Chars Set C) contains the set of 100 digit pairs from 00 to 99 inclusive, as well as three special characters. This allows numeric data to be encoded as two data digits per symbol character, at effectively twice the density of standard data.
Special characters of Code 128 barcode

The last seven characters of Code Sets A and B (character values 96 - 102) and the last three characters of Code Set C (character values 100 - 102) are special non-data characters with no ASCII character equivalents, which have particular significance to the bar code reading device.
How to Use C# Class Library to Create Code 128 Barcode Image?

How to Install

  1. Add Barcodelib.Barcode.ASP.NET.dll or BarcodeLib.Barcode.WinForms.dll to your C# project reference.
    • Click "Project" and select "Add Reference...".
    • Click "Browse" to find your unzipped above two dll and click "OK" button.
  2. Add BarcodeLib barcoding dlls to Visual Studio Toolbox.
    • Right click in Toolbox and select "Choose Items...".
    • In the pop-up window, click "Browse..." to locate the dll BarcodeLib.Barcode.WinFroms.dll or Barcodelib.Barcode.ASP.NET.dll.
    • Click "OK" and you will find four items listed in VS Toolbox, for example: LinearWinForm, DataMatrixWinForm, PDF417WinForm, and QRCodeWinForm. And now it's done!

How to Implement

You may use the C# sample code below to test our C#.NET Barcode Generator library.
In addition, please feel free to customize the image using advanced Code 128 barcoding features.
     BarcodeLib.Barcode.Linear code128 = new BarcodeLib.Barcode.Linear();
code128.Type = BarcodeType.CODE128;
code128.Data = "CODE128 barcode";

code128.AddCheckSum = true;
code128.UOM = UnitOfMeasure.PIXEL;

// Set Code 128 barcode image size and quiet zones.
code128.BarWidth = 1;
code128.BarHeight = 82;
code128.LeftMargin = 10;
code128.RightMargin = 10;
code128.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;

// More Code 128 barcode settings here, like image color, font, human-readable text font etc.

// save barcode image into your system
code128.drawBarcode("c:/code128.jpg");

// Encode Code 128 barcode & output to byte array
byte[] barcodeInBytes = code128.drawBarcodeAsBytes();

// Encode Code 128 barcode to Graphics object
Graphics graphics = ...;
code128.drawBarcode(graphics);

// Encode Code 128 barcode and output to HttpResponse object
HttpResponse response = ...;
code128.drawBarcode(response);

// Encode Code 128 barcode and output to Stream object
Stream stream = ...;
code128.drawBarcode(stream);
Above Free Code 128 sample code is written in Visual C# 2005
How to Use C# Class DLL to Generate Code 128 Barcode Image for ASP.NET Web?
With this C# Code 128 generator component, you can stream Code 128 barcode images in ASP.NET in two ways.
  1. Method 1: 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, please open your web browser and navigate to:
      http://YourDomain:port/barcode/linear.aspx?Type=2&Data=CODE128
      For further Code 128 barcode setting, please view more web stream Code 128 URL parameters here: Code 128 .NET Generator DLL Property Settings.
    • To add this Code 128 image in your aspx or html page, you can pass the url to IMG tag or src value.
      For example:
      <img src=http://YourDomain:port/barcode/linear.aspx?Type=2&Data=CODE128 />
      This method will not generate any barcode images in your IIS server side.
  2. Method 2: Through ASP.NET web form controller.
    • Integrate 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 "linear.aspx", "linear.aspx.cs" to the aspx page, in which you will be generating Code 128 images.
    • Now you can drag LinearASPNET to your ASP.NET web site, and change Code 128 settings through properties window on the right or use above free Visual C# source code.
    • Debug and you will see the Code 128 barcode generated on your aspx pages.
How to Use C# Class DLL to Generate Code 128 Barcodes for Windows Forms?
  1. Add reference to BarcodeLib.Barcode.WinForms.dll to your barcoding project.
  2. Add BarcodeLib.Barcode.WinForms.dll to your Visual Studio toolbox.
  3. Now please drag the LinearWinForm to your windows form or use above free Visual C# source code, and a Code 128 barcode is generated.
Barcode Generator Library for C# Supported Barcode Images
C# 1D Barcode Generation:
C# 2D Barcode Generation:
Barcode Control for C# - Generates Linear Barcodes: Codabar, Code 11, Code 2 of 5, Code 39, Code 93, EAN-8, EAN-13, Interleaved 2 of 5, ITF-14 (UPC Shipping Container Symbol), Code 128, EAN 128/GS1 128, MSI Plessey, Intelligent Mail, Planet, Postnet, RM4SCC (British Royal Mail), UPC-A, UPC-E.
Barcode Control for C# - Generates 2D Barcodes: Data Matrix, PDF 417, QR Code.