Data Masking
Data Masking allows you to serialize data items by specifying a Mask string as well as an increment string. Data Masking can be used with TextItem as well as BarcodeItem
Data Masking consists of the following concepts:
The input Mask string: The mask string must be specified to the
Mask
property of any TextItem or BarcodeItem objects. The length of the mask string defines the number of characters to be formatted or masked. The mask is aligned to the characters in the target string (i.e. theText
property for TextItem objects or theCode
property for BarcodeItem objects) starting with the right-most position. The input mask string must consist of the following characters (a.k.a. Mask String placeholders):- D or d (for Decimal numeric 0-9)
- H or h (for Hexadecimal 0–9 plus a-f or A-F)
- O or o (for Octal 0–7)
- A or a (for Alphabetic A–Z or a–z)
- N or n (for Alphanumeric 0–9 plus A–Z or a–z)
- % (Ignore character or skip)
The Mask Increment string: The mask increment string (which is set up by using the
MaskIncrement
property of any TextItem or BarcodeItem object) is the value to be added to the text on each label to be printed and should match the Mask string length. The default value for the increment is equivalent to a decimal value of 1 (one). The string is composed of any characters defined in the input mask string. Invalid characters are assumed to be equal to a value of 0 (zero) in that characters position. The increment value for alphabetic strings start with 'A' or 'a' as the zero placeholder. This means to increment an alphabetic character by one, a value of 'B' or 'b' must be in the increment string. For characters that do not get incremented, the '%' character needs to be added to the increment string.
In the following sample, each label features a TextItem which will serialize a product model ranging from "MDL-001/X" to "MDL-010/X" (i.e. the sequence will be MDL-001/X, MDL-002/X, MDL-003/X, ..., MDL-010/X) and a BarcodeItem which will serialize a product ID ranging from "PRD000-A" to "PRD900-J" (i.e. the sequence will be "PRD000-A", "PRD100-B", "PRD200-C", ..., "PRD900-J") in Code 128 symbology.
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, "MDL-001/X")
'set Mask info...
txt.Mask = "%%%%ddd%%"
txt.MaskIncrement = "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, "PRD000-A")
'set Mask info...
bc.Mask = "%%%d%%%A"
bc.MaskIncrement = "1%%%B"
'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, "MDL-001/X");
//set Mask info...
txt.Mask = "%%%%ddd%%";
txt.MaskIncrement = "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, "PRD000-A");
//set Mask info...
bc.Mask = "%%%d%%%A";
bc.MaskIncrement = "1%%%B";
//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);
}