KA.Barcode Generator for .NET Suite
How to Generate Code 128 Image in C# Projects
Complete C# source code to generate Code 128 images in different image formats using Barcode for .NET

C# Barcode Code 128 Generator: create, generate, render Code 128 from string. No font required

  • Powerful .NET barcode generator component to print Code 128A, Code 128B, Code 128C in C#.NET
  • Easy-to-use barcode generator provided, such as .NET WinForms barcode, Word barcode, Java barcode & ASP.NET barcode
  • Paint, draw Code 128 images in Windows applications, ASP.NET web forms, Crystal Reports, C#.NET class
  • Generate Code 128 in Png, Jpg, Gif, Tiff, Bmp image format and save to image files
  • Compatible with ISO/IEC 15417 Code 128 bar code symbology specification to ensure validity of generated images
  • Support Code 128 image rotation through orientation setting in 0, 90, 180, 270 degrees
  • Resolution adjustable through DPI setting to print Code 128 with outstanding quality
  • Provide detailed generation guides online, such as Excel barcode generation, C# barcode integration & Java barcode integration
  • Checksum digit and quiet zones automatically added as specified in Code 128 standard
Code 128 is also named as ANSI/AIM 128, Uniform Symbology Specification Code 128, USS Code 128. KA.Barcode Generator for .NET Suite is a professional barcode generation control SDK for high-quality Code 128A, Code 128B, Code 128C in .NET C#.NET class library. This page is a C#.NET tutorial for Code 128 image setting, and you can get more C# code on Code 128 data encoding and size setting here.
Barcode Size Setting of Code 128 in C#.NET
Barcode Data Encoding of Code 128 in C#.NET
How to Generate, Specify Code 128 Barcode Images in C# Class

Install KA.Barcode Generator for .NET Suite into C#.NET Project

  1. 1.
  2. 2.
    Add Reference: Add "KeepAutomation.Barcode.Window.dll" to your C#.NET project reference.
Copy the following C#.NET Code onto your project to create a Code 28 barcode image
using KeepAutomation.Barcode.Bean;

BarCode code128= new BarCode();
code128.Symbology = KeepAutomation.Barcode.Symbology.Code128C;
code128.CodeToEncode = "0128";
code128.X =2;

Code 128 Barcode Margins / Quiet Zones

According to the ISO/IEC 15417 Code 128 bar code symbology specification, a minimum 10X (10 times the width of the module bar) Quiet Zone margin is required on the left and right sides of the barcode images. This 10X quiet zones are automatically added by KA.Barcode Generator for .NET Suite to ensure readability. Default value for margin is 0. Copy the demo code below into your C#.NET projec to add extra margins.
code128.LeftMargin = 2;
code128.RightMargin = 2;
code128.TopMargin = 2;
code128.BottomMargin = 2;

Code 128 Image Formats

KeepAutomation barcode generator for C#.NET supports printing Code 128 barcodes in different image formats, including Png, Jpeg/Jpg, Gif, Tiff, Bmp, etc. Copy the C# sample code below and save Code 128 barcodes to specific image file.
code128.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

Code 128 Barcode Unit

KA.Barcode Generator for .NET Suite provides three units of measure for Code 128 image generation: Pixel, Cm and Inch. The default value is Pixel. Copy the demo code below to customize this parameter.
code128.BarcodeUnit = BarcodeUnit.Pixel;

Code 128 Image Resolution

If you want to print Code 128 images with outstanding quality which go with all printers, you can adjust Code 128 image resolution through DPI setting, which is short for Dots per Inch. DPI default value is 72 for the generated Code 128 barcode images.
code128.DPI = 72;   

Code 128 Image Orientation

In case you want to adjust Code 128 orientation, i.e. the barcode rotation angle, KA.Barcode Generator for .NET Suite provides four types of barcode orientations for you to choose from: 0 degree, 90 degrees, 180 degrees, and 270 degrees.
code128.Orientation = KeepAutomation.Barcode.Orientation .Degree90