65873 members! Sign up to stay informed.

Sponsored Links


Resources

.NET Research Library
Get .NET related white papers, case studies and webcasts

Industry news Industry news Industry news Messages: 0 Messages: 0 Messages: 0 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

How to print UPS Maxicode barcode with Zebra ZPL-EPL printers...

Posted by: Neodynamic Components on October 27, 2009 DIGG
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
Recent active threads Recent active threads Recent active threads More More More
[Volumes]:Buy and Sell Blackberry 8830 Housing
Transferring current project to Mysql
biztalk workflow/rule engine
I need solutions for below questions
How to data binding ADO.NET DataSet Access or SQL Server DB...
RazorSQL SQL Editor and Database Query Tool Available
Service Pack 2 for TX Text Control RapidSpell .NET 15.0 released
How to create dynamic Folded Corners effect through ImageDraw im
An Evaluation of Windward Reports
More active threads »
Top posters of the weekTop posters of the weekTop posters of the week
This list contains the members who have made the most posts in all forums over the last 7 days:
  1. muthya prasad
  2. SHERRYSLC SHERRYSLC
  3. Richardson Software
  4. Guru Talend
  5. Neodynamic Components
Hot threads Hot threads Hot threads More hot threads More hot threads More hot threads

Eclipse vs. Visual Studio at EclipseCon 2006

Speaking at EclipseCon 2006, Java developer and independent consultant Madhu Siddalingaiah compared Microsoft's Visual Studio IDE to the open source development environment of Eclipse.
(33 comments, last posted July 13, 2009)

Tech Talk: Peter Provost on CAB and Agile development

In this tech talk, Microsoft's Peter Provost talks about the design of the Composite UI Application Block and how the p&p team has led Microsoft in the adoption of Agile methodologies.
(0 comments, last posted April 17, 2006)

Book excerpt: Framework Design Guidelines

Chapter 4 of Framework Design Guidelines, titled "Type Design Guidelines," presents patterns that describe when and how to design classes, constructs and interfaces. In this chapter, Abrams and Cwalina divide types into four groups and discuss the do's and don'ts of type design.
(2 comments, last posted July 07, 2006)

Q&A: Miguel "Mono Man" De Icaza

Paul Ferrill caught up with prime open-source .NET applications driver Miguel De Icaza at Novell's BrainShare conference last week. They discussed the status of Windows Forms for Mono (it's coming along) and VB.NET for Mono (it looks like it's out).
(5 comments, last posted March 30, 2006)

Tech Talk: Jack Greenfield on software factories and DSLs

In this tech talk, Microsoft Visual Studio architect Jack Greenfield discusses the company's approach to Domain-Specific Languages, or DSLs, and the part they play in software factories.
(0 comments, last posted March 15, 2006)
More hot threads »

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
All Content Copyright ©2007 TheServerSide Privacy Policy      Powered by JIVE
Site Map