How to print UPS Maxicode barcode with Zebra ZPL-EPL printers and VB.NET or C# by using ThermalLabel SDK for .NET

Prerequisites
- Neodynamic ThermalLabel SDK 2.0 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) or EPL (Eltron Programming Language)

All Zebra (ZPL-based and EPL-based) thermal barcode printers provide built-in support for printing UPS Maxicode barcodes as well as other barcode standards.

MaxiCode is a two-dimensional barcode, optically read i.e. not scanned, originally created and used by United Parcel Service (UPS). It is suitable for tracking and managing the shipment of packages.

Maxicode supports a set of Modes (from 2 to 6). When using Mode 2 and 3, the value to encode in a Maxicode symbol must fit the following message structures:

UPS Maxicode Mode 2 message format or structure
- 3-digit class of service
- 3-digit country zip code. Mode 2 supports the US Country Code (840). For other country codes please use Mode 3 instead.
- 5-digit zip code
- 4-digit zip code extension (if none exists, four zeros 0000 must be specified)
- [)>RS (Message Header)
- 01GS96 (Format Header)
- <tracking number> (Mandatory Data for UPS)
- GS<SCAC> (Mandatory Data for UPS)
- GS<UPS shipper number>
- GS<Julian day of pickup>
- GS<shipment ID number>
- GS<n/x> (Package n/x)
- GS<package weight>
- GS<address validation>
- GS<ship to street address>
- GS<ship to city>
- GS<ship to state>
- RS
- EOT (End of Message)

Where GS (ASCII 29) is used to separate fields in a message; RS (ASCII 30) is used to separate format types; and EOT (ASCII 4) is the end of transmission characters.

UPS Maxicode Mode 3 message format or structure
- 3-digit class of service
- 3-digit country zip code. Mode 3 is used for non-US Country Code. For US Country Code (840) please use Mode 2 instead.
- 6-alphanumeric characters zip code (A through Z or 0 to 9)
- [)>RS (Message Header)
- 01GS96 (Format Header)
- <tracking number> (Mandatory Data for UPS)
- GS<SCAC> (Mandatory Data for UPS)
- GS<UPS shipper number>
- GS<Julian day of pickup>
- GS<shipment ID number>
- GS<n/x> (Package n/x)
- GS<package weight>
- GS<address validation>
- GS<ship to street address>
- GS<ship to city>
- GS<ship to state>
- RS
- EOT (End of Message)

Where GS (ASCII 29) is used to separate fields in a message; RS (ASCII 30) is used to separate format types; and EOT (ASCII 4) is the end of transmission characters.

In this guide you will learn how to print UPS Maxicode barcodes in both Mode 2 and Mode 3 with Zebra ZPL 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 UPS Maxicode in Mode 2
Encoding 5 digit numeric US postal (zip) code padded with 4 zero's(0). Country code is 840 and Zip Code is 10045-0000.

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.MaxiCode, "")
'Compose Mode 2 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode2
Dim GS As Char = Convert.ToChar(29)
Dim RS As Char = Convert.ToChar(30)
Dim EOT As Char = Convert.ToChar(4)
bc.Code = "002840100450000[)>" + RS + "01" + GS + "961Z00136071" + GS + "UPSN" + GS + "123X56" + GS + "028" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "NEW YORK" + GS + "NY" + RS + EOT

'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.MaxiCode, "");
//Compose Mode 2 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode2;
char GS = Convert.ToChar(29);
char RS = Convert.ToChar(30);
char EOT = Convert.ToChar(4);
bc.Code = "002840100450000[)>" + RS + "01" + GS + "961Z00136071" + GS + "UPSN" + GS + "123X56" + GS + "028" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "NEW YORK" + GS + "NY" + RS + EOT;

//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.MaxiCode, "")
'Compose Mode 2 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode2
Dim GS As Char = Convert.ToChar(29)
Dim RS As Char = Convert.ToChar(30)
Dim EOT As Char = Convert.ToChar(4)
bc.Code = "002840100450000[)>" + RS + "01" + GS + "961Z00136071" + GS + "UPSN" + GS + "123X56" + GS + "028" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "NEW YORK" + GS + "NY" + RS + EOT

'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.MaxiCode, "");
//Compose Mode 2 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode2;
char GS = Convert.ToChar(29);
char RS = Convert.ToChar(30);
char EOT = Convert.ToChar(4);
bc.Code = "002840100450000[)>" + RS + "01" + GS + "961Z00136071" + GS + "UPSN" + GS + "123X56" + GS + "028" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "NEW YORK" + GS + "NY" + RS + EOT;

//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 UPS Maxicode in Mode 3
Encoding 4 digit alpha-numeric UK postal code, padded with 2 trailing spaces to equal 6 characters as required by Mode 3 message format. Country Code is 826 and Postal Code is RS19 followed by two spaces.

Add another 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.MaxiCode, "")
'Compose Mode 3 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode3
Dim GS As Char = Convert.ToChar(29)
Dim RS As Char = Convert.ToChar(30)
Dim EOT As Char = Convert.ToChar(4)
bc.Code = "066826RS19 [)>" + RS + "01" + GS + "961Z00136111" + GS + "UPSN" + GS + "123X56" + GS + "057" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "WEST SWINDON" + GS + RS + EOT

'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.MaxiCode, "");
//Compose Mode 3 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode3;
char GS = Convert.ToChar(29);
char RS = Convert.ToChar(30);
char EOT = Convert.ToChar(4);
bc.Code = "066826RS19 [)>" + RS + "01" + GS + "961Z00136111" + GS + "UPSN" + GS + "123X56" + GS + "057" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "WEST SWINDON" + GS + RS + EOT;

//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.MaxiCode, "")
'Compose Mode 3 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode3
Dim GS As Char = Convert.ToChar(29)
Dim RS As Char = Convert.ToChar(30)
Dim EOT As Char = Convert.ToChar(4)
bc.Code = "066826RS19 [)>" + RS + "01" + GS + "961Z00136111" + GS + "UPSN" + GS + "123X56" + GS + "057" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "WEST SWINDON" + GS + RS + EOT

'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.MaxiCode, "");
//Compose Mode 3 message and set Code property...
bc.MaxiCodeMode = MaxiCodeModes.Mode3;
char GS = Convert.ToChar(29);
char RS = Convert.ToChar(30);
char EOT = Convert.ToChar(4);
bc.Code = "066826RS19 [)>" + RS + "01" + GS + "961Z00136111" + GS + "UPSN" + GS + "123X56" + GS + "057" + GS + GS + "001/001" + GS + "011" + GS + "N" + GS + GS + "WEST SWINDON" + GS + RS + EOT;

//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.

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