How to print a set of barcode labels in batch using counter 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)

Counters allow you to index data items by a selected increment or decrement value, making the data items increase or decrease by a specified value each time a label is printed. Counters can be used with TextItem as well as BarcodeItem objects. The first integer number found in the Text property (for TextItem objects) or Code property (for BarcodeItem objects) when scanning from right to left starts the indexing portion of the data item. If the alphanumeric field to be indexed ends with an alpha character, the data is scanned, character by character, from right to left until a numeric character is encountered.

In this guide you will learn how to print 10 barcode labels for values ranging from "ABC01" to "ABC10" leveraging counters feature 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.
- Open Visual Studio 2005 / 2008 and create a Windows Forms application.
- 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 TextItem object
Dim txt As New TextItem(1, 1, "Decreasing 50")
'Set font...
txt.Font.CharHeight = 14
'set Counter...
txt.CounterStep = -1

'Define a BarcodeItem object
Dim bc As New BarcodeItem(1, 2, BarcodeSymbology.Code128, "ABC01")
'Set bars' width and height...
bc.BarWidth = 0.04
bc.BarHeight = 2
'set Counter...
bc.CounterStep = 1
bc.CounterUseLeadingZeros = True

'Add items to ThermalLabel object...
tLabel.Items.Add(txt)
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"
'Set Copies to 10!!!
pj.Copies = 10
'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 TextItem object
TextItem txt = new TextItem(1, 1, "Decreasing 50");
//Set font...
txt.Font.CharHeight = 14;
//set Counter...
txt.CounterStep = -1;

//Define a BarcodeItem object
BarcodeItem bc = new BarcodeItem(1, 2, BarcodeSymbology.Code128, "ABC01");
//Set bars' width and height...
bc.BarWidth = 0.04;
bc.BarHeight = 2;
//set Counter...
bc.CounterStep = 1;
bc.CounterUseLeadingZeros = true;

//Add items to ThermalLabel object...
tLabel.Items.Add(txt);
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";
//Set Copies to 10!!!
pj.Copies = 10;
//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