C# GS1-128 Barcode Data Encoding
How to encode GS1 data in GS1-128 barcode using C#
In this C# tutorial, you will learn how to generate GS1-128 barcode with valid GS1 data message in .NET ASP.NET, Windows applications.
- GS1 supported character set
- GS1-128 barcode structure
- Data encoding in GS1-128
How to create GS1-128/EAN-128 barcodes using C#
C# GS1 128 Overview
The GS1 system originated in the United States and was established in 1973 by the Uniform Product Code Council, known until recently as the Uniform Code Council, Inc. (UCC) and since 2005 as GS1 US.
GS1-128, former known as EAN-128, UCC-128, USS-128, is alphanumeric linear barcode developed on Code 128, however, using GS1 standard.
The GS1-128 barcode is a subset of the Code 128 barcode symbology. Its use is exclusively licenced to GS1. This extremely flexible symbology encodes element strings using GS1 Application Identifiers.
C# GS1 128 is a GS1 128 generator for C# development which a detailed C# source code about generating GS1-128 barcodes in C# class using Barcode in C# generation component. C# GS1 128 generator supports various image setting, such as bar alignment, image color, image rotation(0, 90, 180, 270), and image formats(png, gif, tiff, bmp and jpeg).
OnBarcode
C# Barcode Generator is designed to generate, create GS1 128 and other linear & 2d barcodes in Microsoft Word.
GS1-128 Encodable character set
- The GS1 system requires that only the subset of ISO/IEC 646 International Reference Version defined in these GS1 General Specifications be used for GS1 Application Identifier (AI) element strings.
- Characters with ASCII values 128 to 255 may also be encoded in Code 128 symbols.
- Four non-data function characters
- Four code set selection characters
- Three start characters
Note: using .NET Barcode Generator SDK, you need provide AI elements data only, the software will add all other characters for you.
GS1-128 barcode structure
The GS1-128 barcode is made up as follows, reading from left to right:
- Left Quiet Zone
- The double character start pattern
- AI Elements Data
- A symbol check character
- The stop character
- Right Quiet Zone
Note: using .NET Barcode Generator SDK, you need provide AI elements data (Data characters area in the below image ) only, the software will add all other characters for you.
GS1 128 data character encodation
Code 128 has three character sets, which are code sets A, B, and C.
- Code Set A: A-Z, 0-9, and seven special characters
- Code Set B: A-Z, a-z, 0-9, and seven special characters
- Code Set C: digit pairs from 00-99 inclusive, and three special characters
Note: using .NET Barcode Generator SDK, the software will automatically choose the best combination of code sets for you. You do need choose Code set manually.
C# example to create a GS1-128 barcode
C# example source code: generate GS1 128 with two AI elements data encoding.
Linear barcode = new Linear();
// encode two AI element
barcode.Data = "(00)395123451234567895(01)09501101530003";
// Barcode symbology type.
barcode.Type = BarcodeType.EAN128;
/*
* Barcode Image Related Settings
*/
// Unit of meature for all size related setting in the library.
barcode.UOM = UnitOfMeasure.PIXEL;
// Bar module width (X), default is 1 pixel;
barcode.X = 2;
// Bar module height (Y), default is 60 pixel;
barcode.Y = 60;
// Barcode image left, right, top, bottom margins. Defaults are 0.
barcode.LeftMargin = 0;
barcode.RightMargin = 0;
barcode.TopMargin = 0;
barcode.BottomMargin = 0;
// Image resolution in dpi, default is 72 dpi.
barcode.Resolution = 72;
// Created barcode orientation.
//4 options are: facing left, facing right, facing bottom, and facing top
barcode.Rotate = Rotate.Rotate0;
/*
* Linear barcodes human readable text styles
*/
// Display human readable text under the barcode
barcode.ShowText = true;
// Human readable text font size, font family and style
barcode.TextFont = new Font("Arial", 9f, FontStyle.Regular);
// Space between barcode and text. Default is 6 pixel.
barcode.TextMargin = 6;
// Generate Code-128 and encode barcode to png format
barcode.Format = System.Drawing.Imaging.ImageFormat.Png;
barcode.drawBarcode("W://Projects//Test-Output//OnBarcode.com//csharp-ean128.png");