Show / Hide Table of Contents

ThermalLabel XML & JSON Templates

ThermalLabel SDK features XML & JSON Template i.e. you can instruct a ThermalLabel object for exporting/importing the label definition in XML or JSON text format. The following is a simple ThermalLabel object which can be saved as XML & JSON Template by invoking the GetXmlTemplate() and GetJsonTemplate() methods respectivelly:

ThermalLabel XML Templates

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 fil
System.IO.File.WriteAllText("C:\temp\myLabel.tl", tLabel.GetXmlTemplate())
'Save label to JSON file
System.IO.File.WriteAllText("C:\temp\myLabel.tlj", tLabel.GetJsonTemplate())

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.tl", tLabel.GetXmlTemplate());
//Save label to JSON file
System.IO.File.WriteAllText(@"C:\temp\myLabel.tlj", tLabel.GetJsonTemplate());

The XML file will contain the following label description.

XML Template

<?xml version="1.0" encoding="utf-8"?>
<ThermalLabel Version="10.0" Width="4" Height="3" GapLength="0.2" MarkLength="0" OffsetLength="0" UnitType="Inch" LabelsPerRow="1" LabelsHorizontalGapLength="0" IsContinuous="False" PrintSpeed="" PrintMirror="False" CutAfterPrinting="False">
  <Items>
    <TextItem X="0.2" Y="0.2" Width="2.5" Text="Thermal_x0020_Label_x0020_Test" Font="NativePrinterFontA,10,Point,,,False,90,,CP850" />
    <BarcodeItem X="0.2" Y="1" Width="2" Height="1" Symbology="Code128" Code="ABC_x0020_12345" BarHeight="0.75" Font="NativePrinterFontA,10,Point,,,False,90,,CP850" TextFont="NativePrinterFontA,10,Point,,,False,90,,CP850" MaxiCodeDrawPixelBasedSymbol="True" DotCodeAspectRatio="" />
  </Items>
</ThermalLabel>

The JSON file will contain the following label description.

JSON Template

{
  "width": 4,
  "height": 3,
  "unitType": "Inch",
  "items": [
    {
      "typeName": "TextItem",
      "text": "Thermal Label Test",
      "font": {
        "name": "NativePrinterFontA",
        "nameAtPrinterStorage": "",
        "size": 10,
        "bold": false,
        "italic": false,
        "underline": false,
        "strikeout": false,
        "unit": "Point",
        "customFontFile": "",
        "customFontFileFamilyName": "",
        "isBitmapFont": false,
        "threshold": 90,
        "codePage": "CP850"
      },
      "foreColor": "Black",
      "foreColorHex": "",
      "rotationAngle": 0,
      "width": 2.5,
      "height": 0.5,
      "counterStep": 0,
      "counterUseLeadingZeros": false,
      "mask": "",
      "maskIncrement": "",
      "rightToLeft": false,
      "sizing": "None",
      "cornerRadius": {
        "topLeft": 0,
        "topRight": 0,
        "bottomRight": 0,
        "bottomLeft": 0
      },
      "borderThickness": {
        "left": 0,
        "top": 0,
        "bottom": 0,
        "right": 0
      },
      "borderColor": "Black",
      "borderColorHex": "",
      "backColor": "White",
      "backColorHex": "",
      "textPadding": {
        "left": 0,
        "top": 0,
        "bottom": 0,
        "right": 0
      },
      "textAlignment": "Left",
      "cultureName": "",
      "maxLength": 0,
      "hideIfEmpty": false,
      "inputMaskPattern": "",
      "inputMaskPromptChar": "_",
      "strokeThickness": 0,
      "strokeColorHex": "",
      "charSpacing": 0,
      "name": "",
      "x": 0.2,
      "y": 0.2,
      "dataField": "",
      "dataFieldFormatString": "",
      "useCache": false,
      "cacheItemId": "",
      "printAsGraphic": false,
      "visible": true,
      "comments": "",
      "tag": "",
      "locked": false,
      "editable": true,
      "expression": "",
      "isDesignTime": false
    },
    {
      "typeName": "BarcodeItem",
      "text": "",
      "barColor": "Black",
      "barColorHex": "",
      "barHeight": 0.75,
      "barWidth": 0.0104,
      "barRatio": 2,
      "rotationAngle": 0,
      "codabarStartChar": "A",
      "codabarStopChar": "A",
      "displayStartStopChar": true,
      "code": "ABC 12345",
      "addChecksum": true,
      "eanUpcGuardBar": true,
      "eanUpcGuardBarHeight": 0.55,
      "code128CharSet": "Auto",
      "planetHeightTallBar": 0.2,
      "planetHeightShortBar": 0.1,
      "postnetHeightTallBar": 0.2,
      "postnetHeightShortBar": 0.1,
      "symbology": "Code128",
      "quietZone": {
        "left": 0.1,
        "top": 0,
        "bottom": 0.02,
        "right": 0.1
      },
      "displayChecksum": true,
      "displayCode": true,
      "textAlignment": "AboveCenter",
      "codeAlignment": "BelowCenter",
      "code16kMode": "Mode1",
      "code39FullAsciiMode": true,
      "code93FullAsciiMode": true,
      "dataMatrixModuleSize": 0.0417,
      "dataMatrixProcessTilde": false,
      "dataMatrixFormat": "Auto",
      "dataMatrixEncoding": "Auto",
      "eanUpcSupplement": "None",
      "eanUpcSupplementTopMargin": 0.15,
      "eanUpcSupplementSeparation": 0.15,
      "eanUpcSupplementCode": "0",
      "upcESystem": "System0",
      "pdf417Rows": 0,
      "pdf417Columns": 0,
      "pdf417ErrorCorrectionLevel": "Level2",
      "pdf417CompactionType": "Auto",
      "pdf417Truncated": false,
      "pdf417ByteEncodingName": "ISO-8859-1",
      "postal4StateTrackerBarHeight": 0.08,
      "postal4StateTrackerBarWidth": 0.0208,
      "postal4StateBarsSpacing": 0.0313,
      "postal4StateAddStartStopChar": true,
      "bearerBarStyle": "None",
      "bearerBarThickness": 0.05,
      "eanUpcDisplayLightMarginIndicator": false,
      "qRCodeModuleSize": 0.0417,
      "qRCodeEncoding": "Auto",
      "qRCodeByteEncodingName": "ISO-8859-1",
      "qRCodeErrorCorrectionLevel": "M",
      "qRCodeVersion": "Auto",
      "uspsFimPattern": "A",
      "uspsHorizontalBarsCount": 10,
      "telepenEncoding": "Ascii",
      "pharmacodeThinBarWidth": 0.0208,
      "pharmacodeThickBarWidth": 0.0625,
      "pharmacodeBarsSpacing": 0.0417,
      "backColor": "White",
      "backColorHex": "",
      "font": {
        "name": "NativePrinterFontA",
        "nameAtPrinterStorage": "",
        "size": 10,
        "bold": false,
        "italic": false,
        "underline": false,
        "strikeout": false,
        "unit": "Point",
        "customFontFile": "",
        "customFontFileFamilyName": "",
        "isBitmapFont": false,
        "threshold": 90,
        "codePage": "CP850"
      },
      "foreColor": "Black",
      "foreColorHex": "",
      "textFont": {
        "name": "NativePrinterFontA",
        "nameAtPrinterStorage": "",
        "size": 10,
        "bold": false,
        "italic": false,
        "underline": false,
        "strikeout": false,
        "unit": "Point",
        "customFontFile": "",
        "customFontFileFamilyName": "",
        "isBitmapFont": false,
        "threshold": 90,
        "codePage": "CP850"
      },
      "textForeColor": "Black",
      "textForeColorHex": "",
      "aztecCodeModuleSize": 0.0417,
      "aztecCodeFormat": "Auto",
      "aztecCodeErrorCorrection": 23,
      "aztecCodeRune": -1,
      "aztecCodeByteEncodingName": "ISO-8859-1",
      "pdf417SegmentIndex": 0,
      "pdf417SegmentCount": 0,
      "pdf417FileId": "000",
      "pdf417AspectRatio": 0,
      "microPdf417Version": "Auto",
      "isbt128DataStructure": "DS001",
      "hibcFormatHumanReadableText": true,
      "useQuietZoneForText": false,
      "barWidthAdjustment": 0,
      "humanReadableText": "",
      "microQRCodeVersion": "Auto",
      "msiChecksum": "OneMod10",
      "segmentsPerRow": 4,
      "maxiCodeMode": "Mode4",
      "maxiCodeProcessTilde": false,
      "maxiCodeSymbolIndex": 1,
      "maxiCodeSymbolCount": 1,
      "aztecCodeProcessTilde": false,
      "qRCodeProcessTilde": false,
      "dataMatrixByteEncodingName": "ISO-8859-1",
      "dataMatrixSymbolCount": 1,
      "dataMatrixSymbolIndex": 1,
      "dataMatrixFileId": "001001",
      "sizing": "None",
      "barcodeAlignment": "TopLeft",
      "cornerRadius": {
        "topLeft": 0,
        "topRight": 0,
        "bottomRight": 0,
        "bottomLeft": 0
      },
      "borderThickness": {
        "left": 0,
        "top": 0,
        "bottom": 0,
        "right": 0
      },
      "borderColor": "Black",
      "borderColorHex": "",
      "barcodePadding": {
        "left": 0,
        "top": 0,
        "bottom": 0,
        "right": 0
      },
      "width": 2,
      "height": 1,
      "counterStep": 0,
      "counterUseLeadingZeros": false,
      "mask": "",
      "maskIncrement": "",
      "hideIfEmpty": false,
      "eanUpcMagnificationFactor": 0,
      "hibcUseIsoIec15434Encoding": false,
      "codeFormatPattern": "",
      "textFormatPattern": "",
      "hanXinCodeByteEncodingName": "ISO-8859-1",
      "hanXinCodeEncoding": "Auto",
      "hanXinCodeErrorCorrectionLevel": "L1",
      "hanXinCodeVersion": "Auto",
      "hanXinCodeModuleSize": 0.0417,
      "hanXinCodeProcessTilde": false,
      "itf14LeftHMark": "None",
      "itf14RightHMark": "None",
      "errorBehavior": "BlankImage",
      "gS1DataStrictValidation": false,
      "maxiCodeDrawPixelBasedSymbol": true,
      "dotCodeModuleSize": 0.0417,
      "dotCodeProcessTilde": false,
      "dotCodeColumns": 0,
      "dotCodeRows": 0,
      "dotCodeAspectRatio": "",
      "dotCodeModuleShape": "Circle",
      "dataMatrixIncludeRectFormatsInAutoMode": false,
      "code11TwoDigitsChecksum": false,
      "tlc39MicroPdf417BarWidth": 0.010416666666666666,
      "tlc39MicroPdf417RowBarHeight": 0.03125,
      "name": "",
      "x": 0.2,
      "y": 1,
      "dataField": "",
      "dataFieldFormatString": "",
      "useCache": false,
      "cacheItemId": "",
      "printAsGraphic": false,
      "visible": true,
      "comments": "",
      "tag": "",
      "locked": false,
      "editable": true,
      "expression": "",
      "isDesignTime": false
    }
  ],
  "gapLength": 0.2,
  "markLength": 0,
  "offsetLength": 0,
  "labelsPerRow": 1,
  "labelsHorizontalGapLength": 0,
  "isContinuous": false,
  "printSpeed": "",
  "printMirror": false,
  "cutAfterPrinting": false,
  "darkness": -1000,
  "expressions": [],
  "sheetLabelsWidth": 0,
  "sheetLabelsHeight": 0,
  "sheetLabelsCount": 0,
  "sheetLabelsMargin": {
    "left": 0,
    "top": 0,
    "bottom": 0,
    "right": 0
  }
}

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.tl"))

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.tl"));

Loading a ThermalLabel JSON Template

For loading a ThermalLabel JSON Template, you must invoke the LoadJsonTemplate() method on a ThermalLabel object. You must pass to the LoadJsonTemplate() method a string representation of the JSON Template content. For example, based on the sample above, you can load the JSON Template from a file as follows:

VB

'Create a ThermalLabel object for loading the JSON template into it
Dim tLabel As New ThermalLabel()
'Load JSON Template File
tLabel.LoadJsonTemplate(System.IO.File.ReadAllText("c:\temp\myLabel.tlj"))

CS

//Create a ThermalLabel object for loading the JSON template into it
ThermalLabel tLabel = new ThermalLabel();
//Load JSON Template File
tLabel.LoadJsonTemplate(System.IO.File.ReadAllText(@"c:\temp\myLabel.tlj"));
Back to top Copyright © 2003- Neodynamic SRL
http://www.neodynamic.com