CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    136

    Thumbs up How to print GS1-128 or UCC EAN 128 barcode with Zebra ZPL printers and VB.NET or C#

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

    Prerequisites
    - Neodynamic ThermalLabel SDK for .NET
    - 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)

    All Zebra (ZPL-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 printers by using ThermalLabel SDK for .NET

    IMPORTANT: To test the sample code you must have installed a Zebra ZPL 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:

    Visual Basic .NET
    'Define a ThermalLabel object and set unit to cm and label size
    Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 8)

    '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 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, 8);

    //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 name
    pj.PrinterSettings.PrinterName = "Zebra TLP2844-Z";
    //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:

    Visual Basic .NET
    'Define a ThermalLabel object and set unit to cm and label size
    Dim tLabel As New ThermalLabel(UnitType.Cm, 10, 8)

    '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 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, 8);

    //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 name
    pj.PrinterSettings.PrinterName = "Zebra TLP2844-Z";
    //Print ThermalLabel object...
    pj.Print(tLabel);

    - Run the sample Windows Forms application and test it.

    Links:
    This Demo
    More Demos
    Download ThermalLabel SDK for .NET
    More Information about Neodynamic ThermalLabel SDK for .NET


    Neodynamic
    .NET Components & Controls
    http://www.neodynamic.com

  2. #2
    Join Date
    Feb 2013
    Posts
    1

    Re: How to print GS1-128 or UCC EAN 128 barcode with Zebra ZPL printers and VB.NET or

    This third party control seems good. But one of my friends recommended me a VB.NET EAN 128 barcode generator SDK. It also has detailed tutorial of generating barcodes in VB.NET. Which one is better?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured