Neodynamic ThermalLabel SDK 8.0+
Microsoft .NET Framework 4.6.1+
Microsoft Visual Studio 2017+
Any Zebra Thermal Printer supporting ZPL (Zebra Programming Language) or EPL (Eltron Programming Language)
ThermalLabel SDK supports .NET Data Binding scenarios allowing you to print thermal labels bound to a data source such as custom .NET objects, XML files, Databases, ADO.NET, CSV files, etc. The data binding settings are very simple. You set up a valid data source to the ThermalLabel object by using the DataSource property. In the label, items like TextItem, ImageItem and BarcodeItem can be bound to fields of the data source by using the DataField property.
The following sample features a CSV (comma-separated values) file called Products.csv containing info about some fictitious items. The csv file contains in the first line (row) the name of the "columns" which in this case are PRODUCT_CODE and PRODUCT_NAME. Those names are the one which must be set up to the DataField property of the item object used for designing the thermal label object.
We'll be designing a label which will print out both fields; the product name as a TextItem and the product code as a Code 128 BarcodeItem. The output will look like the following figure:
'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 for product name
Dim txt As New TextItem(0.1, 0.1, 2.8, 0.5, "")
'set data field which must match some field/column name of the first row in the CSV file
txt.DataField = "PRODUCT_NAME"
'set font
txt.Font.Name = "Arial"
txt.Font.Unit = FontUnit.Point
txt.Font.Size = 16
'set border
txt.BorderThickness = New FrameThickness(0.03)
txt.CornerRadius = New RectangleCornerRadius(0.1, 0.1, 0, 0)
'set alignment
txt.TextAlignment = TextAlignment.Center
txt.TextPadding = New FrameThickness(0, 0.1, 0, 0)
'Define a BarcodeItem object for encoding product id with a Code 128 symbology
Dim bc As New BarcodeItem(0.1, 0.57, 2.8, 1.3, BarcodeSymbology.Code128, "")
'set data field which must match some field/column name of the first row in the CSV file
bc.DataField = "PRODUCT_CODE"
'set barcode size
bc.BarWidth = 0.01
bc.BarHeight = 0.75
'set barcode alignment
bc.BarcodeAlignment = BarcodeAlignment.MiddleCenter
'set text alignment
bc.CodeAlignment = BarcodeTextAlignment.BelowJustify
'set border
bc.BorderThickness = New FrameThickness(0.03)
bc.CornerRadius = New RectangleCornerRadius(0, 0, 0.1, 0.1)
'Add items to ThermalLabel object...
tLabel.Items.Add(txt)
tLabel.Items.Add(bc)
'set data source to a CSV file...
tLabel.DataSource = "c:\products.csv"
'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 PrintJob
pj.PrinterSettings = myPrinter
'Print ThermalLabel object...
pj.Print(tLabel)
End Using
//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 for product name
TextItem txt = new TextItem(0.1, 0.1, 2.8, 0.5, "");
//set data field which must match some field/column name of the first row in the CSV file
txt.DataField = "PRODUCT_NAME";
//set font
txt.Font.Name = "Arial";
txt.Font.Unit = FontUnit.Point;
txt.Font.Size = 16;
//set border
txt.BorderThickness = new FrameThickness(0.03);
txt.CornerRadius = new RectangleCornerRadius(0.1, 0.1, 0, 0);
//set alignment
txt.TextAlignment = TextAlignment.Center;
txt.TextPadding = new FrameThickness(0, 0.1, 0, 0);
//Define a BarcodeItem object for encoding product id with a Code 128 symbology
BarcodeItem bc = new BarcodeItem(0.1, 0.57, 2.8, 1.3, BarcodeSymbology.Code128, "");
//set data field which must match some field/column name of the first row in the CSV file
bc.DataField = "PRODUCT_CODE";
//set barcode size
bc.BarWidth = 0.01;
bc.BarHeight = 0.75;
//set barcode alignment
bc.BarcodeAlignment = BarcodeAlignment.MiddleCenter;
//set text alignment
bc.CodeAlignment = BarcodeTextAlignment.BelowJustify;
//set border
bc.BorderThickness = new FrameThickness(0.03);
bc.CornerRadius = new RectangleCornerRadius(0, 0, 0.1, 0.1);
//Add items to ThermalLabel object...
tLabel.Items.Add(txt);
tLabel.Items.Add(bc);
//Set the data source to a CSV file...
tLabel.DataSource = @"c:\products.csv";
//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 PrintJob
pj.PrinterSettings = myPrinter;
//Print ThermalLabel object...
pj.Print(tLabel);
}
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.