Defines functions used for interacting with printer formats.
Namespace: Zebra.Sdk.PrinterAssembly: SdkApi.Core (in SdkApi.Core.dll) Version: 3.0.3271
Syntax public interface FormatUtil
Public Interface FormatUtil
public interface class FormatUtil
The FormatUtil type exposes the following members.
Methods | Name | Description |
---|
| GetVariableFields |
Returns a list of descriptors of the variable fields in this format.
|
| PrintStoredFormat(String, DictionaryInt32, String) |
Prints a stored format on the printer, filling in the fields specified by the Dictionary.
|
| PrintStoredFormat(String, String) |
Prints a stored format on the printer, filling in the fields specified by the array.
|
| PrintStoredFormat(String, DictionaryInt32, String, String) |
Prints a stored format on the printer, filling in the fields specified by the Dictionary.
|
| PrintStoredFormat(String, String, String) |
Prints a stored format on the printer, filling in the fields specified by the array.
|
| RetrieveFormatFromPrinter(String) |
Retrieves a format from the printer.
|
| RetrieveFormatFromPrinter(Stream, String) |
Retrieves a format from the printer.
|
TopExample using System;
using System.Collections.Generic;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Printer;
public class FormatUtilExample {
public static void Main(string[] args) {
try {
new FormatUtilExample().Example1();
new FormatUtilExample().Example2();
new FormatUtilExample().Example3();
} catch (ConnectionException e) {
Console.WriteLine(e.ToString());
}
}
private void Example1() {
Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.Open();
ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);
Dictionary<int, string> vars = new Dictionary<int, string> {
{ 12, "John" },
{ 11, "Smith" }
};
printer.PrintStoredFormat("E:FORMAT1.ZPL", vars);
} catch (ConnectionException e) {
Console.WriteLine(e.ToString());
} catch (ZebraPrinterLanguageUnknownException e) {
Console.WriteLine(e.ToString());
} finally {
connection.Close();
}
}
private void Example2() {
Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.Open();
ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection);
ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter);
if (linkOsPrinter != null) {
Dictionary<int, string> vars = new Dictionary<int, string> {
{ 12, "John" },
{ 11, "Smith" },
{ 13, "R:PIC.GRF" }
};
linkOsPrinter.PrintStoredFormatWithVarGraphics("E:FORMAT2.ZPL", vars);
}
} catch (ConnectionException e) {
Console.WriteLine(e.ToString());
} catch (ZebraPrinterLanguageUnknownException e) {
Console.WriteLine(e.ToString());
} finally {
connection.Close();
}
}
private void Example3() {
Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.Open();
ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);
Dictionary<int, string> vars = new Dictionary<int, string> {
{ 12, "东风伟世通汽车饰件系统有限公司" },
{ 11, "订单号" },
{ 13, "供应商名称" }
};
printer.PrintStoredFormat("E:FORMAT3.ZPL", vars, "UTF-8");
} catch (ConnectionException e) {
Console.WriteLine(e.ToString());
} catch (ZebraPrinterLanguageUnknownException e) {
Console.WriteLine(e.ToString());
} finally {
connection.Close();
}
}
}
See Also