ThermalLabel XML Templates
ThermalLabel SDK features XML Template i.e. you can instruct a ThermalLabel object for exporting/importing the label definition in XML text format. The following is a simple ThermalLabel object which can be saved as an XML Template by invoking the GetXmlTemplate() method:
VB
'Define a ThermalLabel object and set unit to inch and label size
Dim tLabel As New ThermalLabel(UnitType.Inch, 4, 3)
tLabel.GapLength = 0.2
'Define a TextItem object
Dim txtItem As New TextItem(0.2, 0.2, 2.5, 0.5, "Thermal Label Test")
'Define a BarcodeItem object
Dim bcItem As New BarcodeItem(0.2, 1, 2, 1, BarcodeSymbology.Code128, "ABC 12345")
'Set bars height to .75inch
bcItem.BarHeight = 0.75
'Set bars width to 0.0104inch
bcItem.BarWidth = 0.0104
'Add items to ThermalLabel object...
tLabel.Items.Add(txtItem)
tLabel.Items.Add(bcItem)
'Save label to XML file
System.IO.File.WriteAllText("C:\temp\myLabel.xml", tLabel.GetXmlTemplate())
CS
//Define a ThermalLabel object and set unit to inch and label size
ThermalLabel tLabel = new ThermalLabel(UnitType.Inch, 4, 3);
tLabel.GapLength = 0.2;
//Define a TextItem object
TextItem txtItem = new TextItem(0.2, 0.2, 2.5, 0.5, "Thermal Label Test");
//Define a BarcodeItem object
BarcodeItem bcItem = new BarcodeItem(0.2, 1, 2, 1, BarcodeSymbology.Code128, "ABC 12345");
//Set bars height to .75inch
bcItem.BarHeight = 0.75;
//Set bars width to 0.0104inch
bcItem.BarWidth = 0.0104;
//Add items to ThermalLabel object...
tLabel.Items.Add(txtItem);
tLabel.Items.Add(bcItem);
//Save label to XML file
System.IO.File.WriteAllText(@"C:\temp\myLabel.xml", tLabel.GetXmlTemplate());
The XML file will contain the following label description.
XML
<?xml version="1.0" encoding="utf-8"?>
<ThermalLabel Width="4" Height="3" GapLength="0.2" UnitType="Inch" LabelsPerRow="1" LabelsHorizontalGapLength="0">
<Items>
<TextItem Name="" X="0.2" Y="0.2" DataField="" CacheItemId="" Width="2.5" Height="0.5" Text="Thermal Label Test" Font="NativePrinterFontA,10,Point,,,False" />
<BarcodeItem Name="" X="0.2" Y="1" DataField="" CacheItemId="" Width="2" Height="1" Symbology="Code128" Code="ABC 12345" BarHeight="0.75" BearerBarThickness="0.05" EanUpcSupplementCode="0" Font="NativePrinterFontA,10,Point,,,False" QuietZone="0.1,0,0.1,0.02" TextFont="NativePrinterFontA,10,Point,,,False" />
</Items>
</ThermalLabel>
Loading a ThermalLabel XML Template
For loading a ThermalLabel XML Template, you must invoke the LoadXmlTemplate() method on a ThermalLabel object. You must pass to the LoadXmlTemplate() method a string representation of the XML Template content. For example, based on the sample above, you can load the XML Template from a file as follows:
VB
'Create a ThermalLabel object for loading the XML template into it
Dim tLabel As New ThermalLabel()
'Load XML Template File
tLabel.LoadXmlTemplate(System.IO.File.ReadAllText("c:\temp\myLabel.xml"))
CS
//Create a ThermalLabel object for loading the XML template into it
ThermalLabel tLabel = new ThermalLabel();
//Load XML Template File
tLabel.LoadXmlTemplate(System.IO.File.ReadAllText(@"c:\temp\myLabel.xml"));