borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincani

AndreaVB Home | News Home | Forum Home | Downloads | Register | Search | PM | Profile

Previous Topic (How to create Crystal Reports featuring barcode images using SQL Stored Procedure in .NET...)Next Topic (Nested mail merge regions & FlatOPC format support by Aspose.Words) New Topic Post Reply
AndreaVB OnLine : News : How to print a set of barcode labels in batch using data masking with Zebra ZPL-EPL printers...
Poster Resource
Neodynamic
Level: Master

Registered: 08-12-2005
Posts: 131
icon How to print a set of barcode labels in batch using data masking with Zebra ZPL-EPL printers...

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

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 objects. 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. the Text property for TextItem objects or the Code 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 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 this guide you will learn how to print 10 barcode labels leveraging Data Masking feature with Zebra ZPL or EPL printers by using ThermalLabel SDK for .NET.
In this 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 standard.

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 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, 6, 0)

  'Define a TextItem object
  Dim txt As New TextItem(0.5, 0.5, "MDL-001/X")
  'Set font...
  txt.Font.CharHeight = 14
  'set Mask...
  txt.Mask = "%%%%ddd%%"
  txt.MaskIncrement = "1%%"

  'Define a BarcodeItem object
  Dim bc As New BarcodeItem(0.5, 1.5, BarcodeSymbology.Code128, "PRD000-A")
  'Set bars' width and height...
  bc.BarWidth = 0.04
  bc.BarHeight = 2
  'set Mask...
  bc.Mask = "%%%d%%%A"
  bc.MaskIncrement = "1%%%B"

  '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 language
  pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
  'Set Thermal Printer name
  pj.PrinterSettings.PrinterName = "Zebra  GK420t"
  '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, 6, 0);

  //Define a TextItem object
  TextItem txt = new TextItem(0.5, 0.5, "MDL-001/X");
  //Set font...
  txt.Font.CharHeight = 14;
  //set Mask...
  txt.Mask = "%%%%ddd%%";
  txt.MaskIncrement = "1%%";

  //Define a BarcodeItem object
  BarcodeItem bc = new BarcodeItem(0.5, 1.5, BarcodeSymbology.Code128, "PRD000-A");
  //Set bars' width and height...
  bc.BarWidth = 0.04;
  bc.BarHeight = 1;
  //set Mask...
  bc.Mask = "%%%d%%%A";
  bc.MaskIncrement = "1%%%B";

  //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 language
  pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
  //Set Thermal Printer name
  pj.PrinterSettings.PrinterName = "Zebra  GK420t";
  //Set Copies to 10!!!
  pj.Copies = 10;
  //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, 6, 0)

  'Define a TextItem object
  Dim txt As New TextItem(0.5, 0.5, "MDL-001/X")
  'Set font...
  txt.Font.Name = "2"
  txt.Font.CharHeight = 14
  txt.Font.CharWidth = 8
  'set Mask...
  txt.Mask = "%%%%ddd%%"
  txt.MaskIncrement = "1%%"

  'Define a BarcodeItem object
  Dim bc As New BarcodeItem(0.5, 1.5, BarcodeSymbology.Code128, "PRD000-A")
  'Set bars' width and height...
  bc.BarWidth = 0.04
  bc.BarHeight = 2
  'set Mask...
  bc.Mask = "%%%d%%%A"
  bc.MaskIncrement = "1%%%B"

  '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 language
  pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.EPL
  'Set Thermal Printer name
  pj.PrinterSettings.PrinterName = "Zebra  GK420t"
  '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, 6, 0);

  //Define a TextItem object
  TextItem txt = new TextItem(0.5, 0.5, "MDL-001/X");
  //Set font...
  txt.Font.Name = "2";
  txt.Font.CharHeight = 14;
  txt.Font.CharWidth = 8;
  //set Mask...
  txt.Mask = "%%%%ddd%%";
  txt.MaskIncrement = "1%%";

  //Define a BarcodeItem object
  BarcodeItem bc = new BarcodeItem(0.5, 1.5, BarcodeSymbology.Code128, "PRD000-A");
  //Set bars' width and height...
  bc.BarWidth = 0.04;
  bc.BarHeight = 1;
  //set Mask...
  bc.Mask = "%%%d%%%A";
  bc.MaskIncrement = "1%%%B";

  //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 language
  pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.EPL;
  //Set Thermal Printer name
  pj.PrinterSettings.PrinterName = "Zebra  GK420t";
  //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

25-11-2009 at 08:36 PM
View Profile Send Email to User Show All Posts Visit Homepage | Add Comment
AndreaVB OnLine : News : How to print a set of barcode labels in batch using data masking with Zebra ZPL-EPL printers...
Previous Topic (How to create Crystal Reports featuring barcode images using SQL Stored Procedure in .NET...)Next Topic (Nested mail merge regions & FlatOPC format support by Aspose.Words)New Topic Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder