Prints a label with the specified layout definition and data.
public void WriteLabel(string format, Dictionary<string, string> varDictionary);
Parameter | Description |
---|---|
string format | A string that identifies a label definition. |
Dictionary<string, string> varDictionary | A collection of key-value pairs to provide data to the variables defined in the label definition. |
The format parameter specifies an identifier to locate a label definition in the printer settings specified in the constructor.
The varDictionary 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 to replace the variable with. If the label definition in the commands and attributes JSON object specifies the VarPrefix and/or the VarPostfix settings, the prefix and/or the postfix will be added to form the complete variable name before the variable substitution logic is applied.
The LabelPrinter class description provides an example label definition called "ItemLabel". The following code snippet defines dictionary entries to replace ItemName$$ and ItemNo$$ in the LabelDataStream setting of ItemLabel.
// Sets up the variable dictionary. Dictionary<string, string> varItemDictionary = new Dictionary<string, string>(); // "ItemName$$" in the label definition will be replaced with // "Honeywell AirGenius 4". varItemDictionary.Add("ItemName", "Honeywell AirGenius 4"); // "ItemNo$$" in the label definition will be replaced with // "92926003104". varItemDictionary.Add("ItemNo", "92926003104"); // Prints the ItemLabel labelPrinter.WriteLabel("ItemLabel", varItemDictionary);