Show / Hide Table of Contents

Counters

Counters allow you to index data items by a selected increment or decrement value, making the data items to increase or decrease by a specified value each time a label is printed. Counters can be used with TextItem as well as BarcodeItem objects.

How it works?

A counter is set up on a TextItem or BarcodeItem object by using the CounterStep property. The CounterStep property can be set up to any integer number which specifies the increment or decrement step depending on if the interger value is positive or negative.

When you enable counter feature on a TextItem or BarcodeItem object, 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.

The following sample features a Counter scenario for printing 10 labels with a Barcode Code-128 for values ranging from "ABC1" to "ABC10" and a text decreasing from 50 to 49.

Counters Sample

VB

'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 3, 2)
tLabel.GapLength = 0.2

'Define a TextItem object 
Dim txt As New TextItem(0.1, 0.1, 2.8, 0.5, "Decreasing 50")
'set counter step for decreasing by 1
txt.CounterStep = -1
'set font
txt.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontA
txt.Font.Unit = FontUnit.Point
txt.Font.Size = 10

'Define a BarcodeItem object
Dim bc As New BarcodeItem(0.1, 0.57, 2.8, 1.3, BarcodeSymbology.Code128, "ABC01")
'set counter step for increasing by 1
bc.CounterStep = 1
'set barcode size
bc.BarWidth = 0.02
bc.BarHeight = 0.75
'set barcode alignment
bc.BarcodeAlignment = BarcodeAlignment.MiddleCenter
'set font
bc.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontA
bc.Font.Unit = FontUnit.Point
bc.Font.Size = 10

'Add items to ThermalLabel object...
tLabel.Items.Add(txt)
tLabel.Items.Add(bc)

'Create a WindowsPrintJob object
Using pj As New WindowsPrintJob()
    'Create PrinterSettings object
    Dim myPrinter As New PrinterSettings()
    myPrinter.Communication.CommunicationType = CommunicationType.USB
    myPrinter.Dpi = 203
    myPrinter.ProgrammingLanguage = ProgrammingLanguage.ZPL
    myPrinter.PrinterName = "Zebra  TLP2844-Z"

    'Set PrinterSettings to WindowsPrintJob
    pj.PrinterSettings = myPrinter
    'Set num of labels to generate
    pj.Copies = 10
    'Print ThermalLabel object...
    pj.Print(tLabel)
End Using

CS

//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 3, 2);
tLabel.GapLength = 0.2;

//Define a TextItem object 
TextItem txt = new TextItem(0.1, 0.1, 2.8, 0.5, "Decreasing 50");
//set counter step for decreasing by 1
txt.CounterStep = -1;
//set font
txt.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontA;
txt.Font.Unit = FontUnit.Point;
txt.Font.Size = 10;

//Define a BarcodeItem object
BarcodeItem bc = new BarcodeItem(0.1, 0.57, 2.8, 1.3, BarcodeSymbology.Code128, "ABC01");
//set counter step for increasing by 1
bc.CounterStep = 1;
//set barcode size
bc.BarWidth = 0.02;
bc.BarHeight = 0.75;
//set barcode alignment
bc.BarcodeAlignment = BarcodeAlignment.MiddleCenter;
//set font
bc.Font.Name = Neodynamic.SDK.Printing.Font.NativePrinterFontA;
bc.Font.Unit = FontUnit.Point;
bc.Font.Size = 10;

//Add items to ThermalLabel object...
tLabel.Items.Add(txt);
tLabel.Items.Add(bc);

//Create a WindowsPrintJob object
using (WindowsPrintJob pj = new WindowsPrintJob())
{
    //Create PrinterSettings object
    PrinterSettings myPrinter = new PrinterSettings();
    myPrinter.Communication.CommunicationType = CommunicationType.USB;
    myPrinter.Dpi = 203;
    myPrinter.ProgrammingLanguage = ProgrammingLanguage.ZPL;
    myPrinter.PrinterName = "Zebra  TLP2844-Z";

    //Set PrinterSettings to WindowsPrintJob
    pj.PrinterSettings = myPrinter;
    //Set num of labels to generate
    pj.Copies = 10;
    //Print ThermalLabel object...
    pj.Print(tLabel);
}
Back to top Copyright © 2003- Neodynamic SRL
http://www.neodynamic.com