-
Notifications
You must be signed in to change notification settings - Fork 1
Label Templates
James Shepherdson edited this page Oct 25, 2020
·
1 revision
LabelTool uses JSON-formatted .lbl template files to define label templates. At the moment, LabelTool does not include a graphical template editor (although this is a desired feature for a future release).
This document describes the formatting and possible elements of a LabelTool .lbl template file.
{
"metadata": {
"version": 1,
},
"physicalProperties": {
"manufacturer": "LabTag",
"productName": "JTTA-52NOT",
"width": 488,
"height": 188
},
"elements": [
{
"type": "text",
"x": 190,
"y": 20,
"width": 215,
"height": 150,
"rotation": 0,
"value": "<span style=\"font-size: 18px; font-family: Arial;\">${initials} #{today}</span><br/><span style=\"font-size: 36px; font-weight: bold; font-family: Arial;\">${prefix}${number}</span><br/><span style=\"font-size: 20px; font-weight: bold; font-family: Arial;\">${details}</span><br/>"
},
{
"type": "barcode",
"x": 460,
"y": 42,
"rotation": 90,
"scale": 3,
"value": "#{uuid}"
},
{
"type": "text",
"x": 18,
"y": 28,
"width": 130,
"height": 130,
"alignment": "center",
"value": "<span style=\"font-size: 24px; font-family: Arial;\">${prefix}</span><br><span style=\"font-size: 42px; font-family: Arial; font-weight: bold;\">${number}</span>"
},
]
}- The root element of the JSON file must be a dictionary.
- The
metadatakey must be a dictionary, which contains a single key,version, with a value of1. -
physicalPropertiesmust be a dictionary, with the following keys:-
manufacturer(optional) — the company that manufactures the physical labels that this template is designed for -
productName(optional) — the name, catalog number, or product ID of the physical labels that this template is designed for -
width— the width of printable area of the label, in dots- for example, for a 300 dpi printer, a label that is 2 inches wide should have a value of
600
- for example, for a 300 dpi printer, a label that is 2 inches wide should have a value of
-
height— the height of the printable area of the label, in dots
-
-
elementsmust be an array of zero or more dictionaries, each of which must contain:-
type— currently either"text"or"barcode" -
x— the x-coordinate, in dots, of the corner of the element's bounding box -
y— the y-coordinate, in dots, of the corner of the element's bounding box - For
textelements:-
width— the width, in dots, of the element's bounding box -
height— the height, in dots, of the element's bounding box -
alignment(optional) — the alignment of text within the bounding box (e.g."leftTop","centerMiddle","rightBottom", etc.) -
rotation(optional) — the rotation of the bounding box
-
- For
barcodeelements:-
scale— the scale of the data blocks in the barcode -
rotation(optional) — the rotation of the bounding box
-
-
value— the textual value of the element (a string, either of plain text or including HTML formatting tags)
-
- Element
valuefields may contain any number of variable label fields - User-provided variable fields are denoted by the form
${variable_name} - Automatically-computed variable fields are denoted by the form
#{variable_name}- Currently, two computed variable fields are available:
#{today}and#{uuid}
- Currently, two computed variable fields are available:
-
textelements can be formatted using HTML and CSS. This HTML and CSS cannot modify text structure or placement, only text styling.- Under the hood, an
NSAttributedStringis created using the built-ininit(html:documentAttributes:)method. - The specific CSS traits and HTML tags that are supported are poorly-documented. Your best bet is simply to test a given tag, and see if it works.
- Under the hood, an