The LabelPrinter class supports the writeLabel method for printing a label.
public void writeLabel(String aFormat,
LabelPrinter.VarDictionary aDictionary) throws LabelPrinterException
The aFormat parameter specifies an identifier to locate a label definition in the printer settings specified in the constructor.
The aDictionary parameter specifies a collection of key-value pairs to provide data to the variables defined in the label definition. The key of a dictionary entry should specify the variable name (without prefix or postfix) and the value should specify the data that replaces the variable.
Using the commands and attributes described in Example Printer Commands and Attributes for Label Printing, you may specify "ItemLabel" in the aFormat parameter to print an item label. The LabelDataStream setting of the ItemLabel definition contains two variables, "ItemName$$" and "ItemNo$$". So you may create a LabelPrinter.VarDictionary object to provide data for these variables.
When you add a dictionary entry, the key name should specify the variable name without the prefix or postfix (for example, "ItemName"). The writeLabel method forms the complete variable name by adding a prefix or a postfix (or both) to the key name "ItemName". For the ItemLabel definition, it only specifies a postfix of "$$" so the complete variable name is "ItemName$$". When "ItemName$$" is found in the label data stream, writeLabel replaces the variable with the value specified for the "ItemName" key in the dictionary.