KA.Barcode for .NET Suite
How to Generate Code 128 in C# Application
How to Generate Linear Code 128 Barcode Images in C#, ASP.NET, WinForms, Crystal & RDLC

C# Code 128 Barcode Generator Library
How to create, render, print barcode code 128 from string with auto checksum, free c# example. no font









  • Print 1D Code 128Auto, Code 128A, Code 128B and Code 128C in Visual C#.NET class library
  • Create Code 128 barcodes in ASP.NET websites, WinForms, Crystal Reports as well as RDLC Reports
  • Advanced calculation to automatically add Code 128 checksum digit compatible with related specification
  • Offer rich setting options for generated images including size, orientation, resolution, font, etc
  • Support multiple Code 128 barcode image formats, including gif, jpeg, png, tiff and bitmap
  • Provide royalty-free and permanent license for this C# Code 128 barcode library

C# Code 128 Barcode Generator Introduction

KA.Barcode Generator for .NET Suite is the best quality barcode encoder which adds 1D Code 128A, Code 128B, Code 128C barcoding features in .NET. When a Code 128 image is generated in C#, the user-friendly interface allows developers to easily adjust various barcoding settings and produce images with a fixed size.
What Is A Code 128 Barcode
Code 128, also named 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, is a self-checking linear barcode which encodes 128 ISO/IEC 646 characters.







Create Code 128 in ASP.NET web apps

Developers can also generate linear Code 128 barcode images in ASP.NET Web applications using this barcode creator control SDK. High-quality Code 128A, Code 128B and Code 128C barcodes can be easily created in ASP.NET websites with component drag-and-drop or Visual C# class library and console applications. What also supported is Code 128 generation in Microsoft IIS. For more information, see
How to create linear, 2d barcodes in ASP.NET Core web apps?.
How to generate barcodes in ASP.NET Core MVC web applications?.
How to print barcode in Visual C# with ASP.NET framework web control.

Generate Code 128 in Windows apps

With this .NET barcode generator class library dll, developers will find it so easy to paint and generate a Code 128 barcode image in Windows Forms applications. You can either drag the control from Toolbox for dynamic barcode generation, or create and save Code 128 graphics to local files with Visual C#.NET class libray. Turn to this page to view more:
How to create barcode in .NET WinForms with Visual C#
How to generate barcodes in WPF .NET Core Windows applications?.

Code 128 Data Message Encoding

Encodable character sets

Code 128 barcode standard supports encoding the following data character sets
  • Full ASCII 128 characters


  • Extended ASCII 128 characters (By default are values 128 - 255 of ISO/IEC 8859-1, Latin Alphabet 1)

  • Special characters (4 function characters, 4 code set shift characters, 3 start and 1 stop characters)
To encode data in Code 128, you can easily pass the encoding data to property CodeToEncode in C# class BarCode

            BarCode code128 = new BarCode();
            code128.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto;
            code128.CodeToEncode = "ABC-123-abc";


Code 128 maximum data length

The Code 128 specification (ISO/IEC 15417) does not specify the maximum number of characters in a single Code 128 barcode image.

However some Code 128 standard application will provide the limits. For example, GS1-128 has limits the maximum length of Code 128 data to 48 characters.


Code 128 Code Sets

To encode data characters efficiently, Code 128 uses three Code Sets to encode data message.
  • Code Sets A: encodes all of the standard upper case alphanumeric characters and punctuation characters together with the control characters.

  • Code Sets B: encodes all of the standard upper case alphanumeric characters and punctuation characters together with the lower case alphabetic characters and seven special characters.

  • Code Sets C: encodes 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.
Using KeepAutomation C# barcode generator library, you do not need analyze your encoding Code 128 data and choose the matched Code 128 Code Set. The barcode generator C# library will automatically choose the best Code Sets combination for you based on your encoding data.

            BarCode code128 = new BarCode();
            code128.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto;
            code128.CodeToEncode = "ABC-123-abc";


With Code 128 type KeepAutomation.Barcode.Symbology.Code128Auto, the barcode library will use the best Code Sets to create Code 128 in C# class.


Code 128 special characters

Code 128 barcode supports the following special characters
  • Function characters: Code 128 Function Characters (FNC) includes 4 characters: FNC1, FNC2, FNC3, FNC4. FNC1 is for GS1 system. FNC4 is to encode extended character set.

  • Code Set shift characters: Code Set A, B, or C and Shift characters shall be used to change from one code set to another.

  • Start/Stop characters: 3 start chars A, B and C define the corresponding code set to be used initially in the symbol.
You do not need know how to encode special characters into Code 128 barcode. The barcode C# library will automatically generate and insert the special characters in the right position in the generated Code 128 barcodes.


Code 128 check sum character

Code 128 barcode contains a mandatory check digit (checksum) character, which is based on module 103 (mod 103).

The Code 128 check character will not be displayed in Code 128 barcode text label, and it will not be returned by the barcode decoder and reader also.
Same as special characters in Code 128, the C# Code 128 generator library will automatically calculate the check digit and insert the check sum character in the end of Code 128 data message in the generated Code 128 symbology.




Code 128 Barcode Text Label
Code 128 text label printed below barcode is also named Code 128 human-readable interpretation (HRI).

Required by Code 128 specification, Code 128 barcode HRI (text label) should apply the following rules.
  • HRI should be printed with the Code 128 symbol barcode.

  • Special characters (function characters, code set shift characters, start/stop characters) shall not be printed.

  • Checksum digit character should not be printed also.

  • Text size and font style are not specified.

  • Text can be printed anywhere in the area surrounding the barcode, as long as quiet zone boundaries are not violated.




Generate Barcode Image in Specified Width and Height
  • Set property AutoSizeAdjust to true

  • Set property DPI to be the same or higher as your printer's resolution

  • Set property BarcodeUnit to inch or cm

  • Set property BarCodeWidth and BarCodeHeight to your required image width and height




GS1-128 Generation using C#
Code 128 barcode is a valid data carrier for GS1 system. To encode GS1 data message in Code 128 barcode, you could learn more information here: How to generate GS1-128 barcodes using C#
Code 128 Property Settings
How to Generate Code 128 in .NET Applications with C#