See Also
Features
Buy Now
Online Help
Demo
Licensing

Back

How to print GS1-128 or UCC EAN 128 barcode with Zebra ZPL-EPL printers and VB.NET or C# by using ThermalLabel SDK for .NET

Prerequisites
  • Neodynamic ThermalLabel SDK v2.0-v3.0 for .NET
    NOTE: This demo works with ThermalLabel SDK v2.0-v3.0 but NOT with v4.0
  • Microsoft .NET Framework 2.0 (or greater)
  • Microsoft Visual Studio 2005 / 2008
  • Microsoft Visual Studio 2005 / 2008 Express Editions (VB, C#, J#, and C++)
  • Any Zebra Thermal Printer supporting ZPL (Zebra Programming Language) or EPL (Eltron Programming Language)
All Zebra (ZPL-based and EPL-based) thermal barcode printers provide built-in support for printing GS1-128 (previously referred to as UCC/EAN-128 or EAN-128) barcodes as well as other barcode standards.

The GS1-128 (a.k.a. UCC/EAN-128) Symbology is a subset of the more general Code 128 Symbology. GS1-128 was developed to provide a worldwide format and standard for exchanging common data between companies. While other barcodes simply encode data with no respect for what the data represents, GS1-128 encodes data and encodes what that data represents. GS1-128 has a list of Application Identifiers (AI) which can be a 2, 3, or 4-digit number that identifies the type of data which follows. By convention, the Application Identifier is enclosed in parentheses when printed below the barcode (the parentheses are only for visual clarity, and are not encoded in the barcode).

In this guide you will learn how to print GS1-128 barcodes with Zebra ZPL and EPL printers by using ThermalLabel SDK for .NET

IMPORTANT: To test the sample code you must have installed a Zebra ZPL-based or EPL-based thermal printer.

Follow these steps:
  • Download and install latest version of Neodynamic ThermalLabel SDK for .NET
  • Open Visual Studio 2005 /2008 and create a Windows Forms application.
  • Add a reference to Neodynamic.SDK.ThermalLabel.dll assembly.
  • Example of encoding Global Trade Item Number (GTIN) 95012345678903 using AI 01 (Shipping Contained Code) in GS1-128. Add a button control onto the form and paste the following code in the click event handler of the button:
    IMPORTANT NOTICE
    Although ThermalLabel SDK supports both ZPL and EPL printers, a label design you write using .NET code like C# or VB.NET will not produce the same output printing under ZPL and EPL printers. If you need to support both printer languages in your project then you will have to design two different labels targeting each printer language separately.
    For ZPL-based Printers Visual Basic .NET
    'Define a ThermalLabel object and set unit to cm and label size
    Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 0)
    
    'Define a BarcodeItem object
    Dim bc As New BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "(01)95012345678903")
    'Set bars' width and height...
    bc.BarWidth = 0.04
    bc.BarHeight = 2           
    'Disable checksum...
    bc.AddChecksum = false
    
    'Add items to ThermalLabel object...
    tLabel.Items.Add(bc)
    
    'Create a PrintJob object
    Dim pj As New PrintJob()
    'Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB
    'Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203
    'Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
    'Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  TLP2844-Z"
    'Print ThermalLabel object...
    pj.Print(tLabel)
    
    Visual C# .NET
    //Define a ThermalLabel object and set unit to cm and label size
    ThermalLabel tLabel = new ThermalLabel(UnitType.Cm, 10, 0);
    
    //Define a BarcodeItem object
    BarcodeItem bc = new BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "(01)95012345678903");
    //Set bars' width and height...
    bc.BarWidth = 0.04;
    bc.BarHeight = 2;
    
    //Add items to ThermalLabel object...
    tLabel.Items.Add(bc);
    
    //Create a PrintJob object
    PrintJob pj = new PrintJob();
    //Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB;
    //Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203;
    //Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
    //Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  TLP2844-Z";
    //Print ThermalLabel object...
    pj.Print(tLabel);
    


    For EPL-based Printers Visual Basic .NET
    'Define a ThermalLabel object and set unit to cm and label size
    Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 0)
    
    'Define a BarcodeItem object
    Dim bc As New BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "0195012345678903")
    'Set bars' width and height...
    bc.BarWidth = 0.04
    bc.BarHeight = 2           
    'Disable checksum...
    bc.AddChecksum = false
    
    'Add items to ThermalLabel object...
    tLabel.Items.Add(bc)
    
    'Create a PrintJob object
    Dim pj As New PrintJob()
    'Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB
    'Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203
    'Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.EPL
    'Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  GK420t"
    'Print ThermalLabel object...
    pj.Print(tLabel)
    
    Visual C# .NET
    //Define a ThermalLabel object and set unit to cm and label size
    ThermalLabel tLabel = new ThermalLabel(UnitType.Cm, 10, 0);
    
    //Define a BarcodeItem object
    BarcodeItem bc = new BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "0195012345678903");
    //Set bars' width and height...
    bc.BarWidth = 0.04;
    bc.BarHeight = 2;
    
    //Add items to ThermalLabel object...
    tLabel.Items.Add(bc);
    
    //Create a PrintJob object
    PrintJob pj = new PrintJob();
    //Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB;
    //Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203;
    //Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.EPL;
    //Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  GK420t";
    //Print ThermalLabel object...
    pj.Print(tLabel);
    
  • Example of encoding and concatenating net weight (4 kg) using AI 31 (Product Net Weight in Kg) with the associated Global Trade Item Number (GTIN) 95012345678903 using AI 01 (Shipping Contained Code) in GS1-128. Add another button control onto the form and paste the following code in the click event handler of the button:
    For ZPL-based Printers Visual Basic .NET
    'Define a ThermalLabel object and set unit to cm and label size
    Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 0)
    
    'Define a BarcodeItem object
    Dim bc As New BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "(01)95012345678903(3102)000400")
    'Set bars' width and height...
    bc.BarWidth = 0.04
    bc.BarHeight = 2           
    'Disable checksum...
    bc.AddChecksum = false
    
    'Add items to ThermalLabel object...
    tLabel.Items.Add(bc)
    
    'Create a PrintJob object
    Dim pj As New PrintJob()
    'Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB
    'Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203
    'Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
    'Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  TLP2844-Z"
    'Print ThermalLabel object...
    pj.Print(tLabel)
    
    Visual C# .NET
    //Define a ThermalLabel object and set unit to cm and label size
    ThermalLabel tLabel = new ThermalLabel(UnitType.Cm, 10, 0);
    
    //Define a BarcodeItem object
    BarcodeItem bc = new BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "(01)95012345678903(3102)000400");
    //Set bars' width and height...
    bc.BarWidth = 0.04;
    bc.BarHeight = 2;
    
    //Add items to ThermalLabel object...
    tLabel.Items.Add(bc);
    
    //Create a PrintJob object
    PrintJob pj = new PrintJob();
    //Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB;
    //Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203;
    //Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
    //Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  TLP2844-Z";
    //Print ThermalLabel object...
    pj.Print(tLabel);
    


    For EPL-based Printers Visual Basic .NET
    'Define a ThermalLabel object and set unit to cm and label size
    Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 0)
    
    'Define a BarcodeItem object
    Dim bc As New BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "01950123456789033102000400")
    'Set bars' width and height...
    bc.BarWidth = 0.04
    bc.BarHeight = 2           
    'Disable checksum...
    bc.AddChecksum = false
    
    'Add items to ThermalLabel object...
    tLabel.Items.Add(bc)
    
    'Create a PrintJob object
    Dim pj As New PrintJob()
    'Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB
    'Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203
    'Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.EPL
    'Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  GK420t"
    'Print ThermalLabel object...
    pj.Print(tLabel)
    
    Visual C# .NET
    //Define a ThermalLabel object and set unit to cm and label size
    ThermalLabel tLabel = new ThermalLabel(UnitType.Cm, 10, 0);
    
    //Define a BarcodeItem object
    BarcodeItem bc = new BarcodeItem(1, 1, BarcodeSymbology.UccEan128, "01950123456789033102000400");
    //Set bars' width and height...
    bc.BarWidth = 0.04;
    bc.BarHeight = 2;
    
    //Add items to ThermalLabel object...
    tLabel.Items.Add(bc);
    
    //Create a PrintJob object
    PrintJob pj = new PrintJob();
    //Thermal Printer is connected through USB
    pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB;
    //Set Thermal Printer resolution
    pj.PrinterSettings.Dpi = 203;
    //Set Thermal Printer language
    pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.EPL;
    //Set Thermal Printer name 
    pj.PrinterSettings.PrinterName = "Zebra  GK420t";
    //Print ThermalLabel object...
    pj.Print(tLabel);
    
  • Run the sample Windows Forms application and test it.
If you need more information or assistance, please contact our .
 Copyright © 2003 - 2012 Neodynamic S.R.L. All rights reserved.