Home  >  .NET Barcode Generator Suite  >  .NET Barcode Generation Guide  >  Generate & Create Code 128 Barcode in .NET Application
Code 128 Barcode Generator Library for C#, ASP.NET, VB.NET
Code 128 .NET Barcode Generator Library is a mature and time-tested .NET barcoding dll. It has helped over 1000 .NET developers generate & create Code 128 barcode images in ASP.NET web application, .NET WinForms project.
.NET Code 128 Linear Barcode Introduction
Code 128 is also known 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.
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.
How to Generate Code 128 Barcode using .NET WinForm Barcode Generating Library
You can generate & print Code 128 barcode images in .NET Windows Forms project within three steps:
  1. Add KeepDynamic.BarCode.Windows.dll to your WinForms project reference
  2. Add KeepDynamic.BarCode.Windows.dll to windows project toolbox
  3. Drag & drop the BarCodeControl item from Visual Studio toolbox to your windows forms project and generated barcode image is Code 128 barcode
How to Generate Code 128 Barcode using ASP.NET Barcode Generating Library
This .NET barcode generator sdk offers .NET developers an easy barcoding solution to create Code 128 barcode images in ASP.NET web application.
  1. Add KeepDynamic.BarCode.AspNet.dll to your ASP.NET web project reference
  2. Add KeepDynamic.BarCode.AspNet.dll to Visual Studio toolbox
  3. Copy "linear.aspx", "linear.aspx.cs" from folder barcode to your ASP.NET project
  4. Drag & drop the BarCodeControl item from toolbox to your ASP.NET Web form pages and created barcode image is Code 128 barcode
  5. You can also change other values of created Code 128 barcode images in the Properties window, like encodable data, barcode size
How to Generate Code 128 Barcode in .NET Project Using C# Code
  1. First, you have to install either KeepDynamic.BarCode.AspNet.dll or KeepDynamic.BarCode.Windows.dll to your C#.NET project by adding reference
  2. Then copy following free sample C# code to generate Code 128 barcode images in .NET project
// generate linear barcode object 
BarCode barcode = new BarCode();

// Set barcode type to Code-128
barcode.SymbologyType = SymbologyType.Code128;

// Enter encodable value to Code128 barcode
barcode.CodeText = "Code128";

// set Code 128 barcode image settings
// Set bar width of Code 128
barcode.X = 3;

// set Code 128 barcode image
barcode.BarCodeWidth = 450;
barcode.BarCodeHeight = 90;

// save generated barcode images to png image file using C#
barcode.drawBarcode("C://kdcode128.png");
View more free sample C# code for Code 128 barcode generation in .NET applications
How to Create Code 128 Barcode Images in .NET Project Using VB.NET Class Code
  1. Integrate either KeepDynamic.BarCode.AspNet.dll or KeepDynamic.BarCode.Windows.dll into your VB.NET project by adding reference
  2. Copy the free VB.NET class code below to create & print Code 128 barcode images in .NET project
' generate linear barcode object 
Dim barcode As New BarCode()

' Set barcode type to Code-128
barcode.SymbologyType = SymbologyType.Code128

' Enter encodable value to Code128 barcode
barcode.CodeText = "Code128"

' set Code 128 barcode image settings
' Set bar width of Code 128
barcode.X = 3

' set Code 128 barcode image
barcode.BarCodeWidth = 450
barcode.BarCodeHeight = 90

' save generated barcode images to png image file using VB.NET
barcode.drawBarcode("C://kdcode128.png")
View more free sample VB.NET code for Code 128 barcode generation in .NET applications
.NET Code-128 Barcodes Properties

Barcode properties HTTP Parameters Default Comments
Code 128 specific properties SymbologyType symbology-type Code128 Type of barcode symbology.

To generate Code 128, you can use each one of the below values:
  • SymbologyType.Code128 (7)
  • SymbologyType.Code128a (8)
  • SymbologyType.Code128b (9)
  • SymbologyType.Code128c (10)
CodeText code-text "1234567890" Code 128 valid character set:

  • All 128 charaters of ASCII (Values of character from 0 to 127)

Code 128 standards contains 103 data symbols only and uses three start codes (Code Set A, B, and C) to encode all 128 ASCII values.

  • SymbologyType.Code128a encode Code Set A, values 00-95 of ASCII
  • SymbologyType.Code128b encode Code Set B, ASCII values 32-127
  • SymbologyType.Code128c encode Code Set C, values 00-99 of ASCII

The above three code sets can be mixed in a single barcode and be automaticaly switched by using the KeepDynamic's Code 128 generator.
EnableChecksum enable-checksum true Code 128 uses a Modulo 103 checksum and this barcode generator will always calculate the checksum to Code 128 automatically.
ProcessTilde process-tilde false If the ProcessTilde property is set as true, you can use the tilde character "~" to specify special characters in the input data.

~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 - 255.
FNC1 fnc1 0 (none) Function Code 1 (FNC1) specifies that a Code 128 barcode is a GS1-128 code.
ApplicationIndicator ai 0 Also known as: Application Identifier. It is used to identify the data type in a symbol and is primarily used in GS1 symbologies.
Symbology properties X x 2 The width of narrow bars and the default value of X is 2 pixels.

You can increase the value of X to enhance the readability of the barcode if the barcode scanners could not read stably the barcode which is set as the default value in X dimension.
Y y 75 Height of a barcode module

The default bar height value is 75 pixels
Resolution resolution 72 This property set the resolution in DPI of a barcode image to be drawn, and the default value that is set to printer is 72 pixels. You can adjust the value to get a custom resolution barcode image.
GraphicsUnit graphics-unit GraphicsUnit.Pixel This is the barcode graphic measurements for all size related settings. 0: pixel; 1: cm; 2: inch. The default value is pixel
Rotate rotate 0 The Rotate property allows you changing the angle of a barcode. The valid values are Rotate0, Rotate 90, Rotate 180, and Rotate 270
DisplayCodeText display-code-text true The default value is true, which makes the encoded data message human readable. Otherwise the data message text will not be displayed on the barcode image
CodeTextFont code-text-font "Arial", Font.PLAIN, 11 CodeTextFont property is used for changing the font style of data message text that can be read by human eyes.
Image properties Format format ImageFormat.Png This is a method that is used for exporting barcode to different type of image formats. It allows developers generate barcode in formats like JPEG/JPG, BMP, GIF, and PNG.

The default method is ImageFormat.Png. Image format type. Using System.Drawing.Imaging.ImageFormat
LeftMargin left-margin 0 The property to set the distance between the symbol and the left margin of a barcode image.
RightMargin right-margin 0 The property to set the distance between the symbol and the right margin of a barcode image.
TopMargin top-margin 0 The property to customize the space between the symbol and the top margin on a barcode image
BottomMargin bottom-margin 0 The property to change the space between the symbol and the bottom margin on a barcode image

.NET Code-128 Barcodes Generator Supported Barcode Types