FormatUtil Interface |
Namespace: Zebra.Sdk.Printer
The FormatUtil type exposes the following members.
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.
|
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()); } } /// Print a stored format with the given variables. This ZPL will store a format on a printer, for use with example1. /// /// ^XA /// ^DFE:FORMAT1.ZPL /// ^FS /// ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS /// ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS /// ^FT258,73^A0N,39,38^FH\^FDVisitor^FS /// ^BY2,4^FT403,376^B7N,4,0,2,2,N^FH^FDSerial Number^FS /// ^FO5,17^GB601,379,8^FS /// ^XZ 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(); } } /// Print a stored format with the given variables. This ZPL will store a format on the Link-OS™ printer, /// for use with Example2. /// /// ^XA /// ^DFE:FORMAT2.ZPL /// ^FS /// ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS /// ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS /// ^FT258,73^A0N,39,38^FH\^FDVisitor^FS /// ^FO100,100^XG^FN13,1,1^FS /// ^FO5,17^GB601,379,8^FS /// ^XZ 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(); } } /// Print a stored format with the given variables. This ZPL will store a format on a printer, for use with example3. /// This example also requires the ANMDS.TTF font to have been download to the printer prior to using this code. /// /// ^XA^DFE:FORMAT3.ZPL /// ^FS /// ^FT26,223^FH^A@N,56,55,E:ANMDS.TTF^CI28^FH\^FN12"Customer Name"^FS /// ^FT26,316^FH\^A@N,56,55,E:ANMDS.TTF^FH\^FN11"Invoice Number"^FS /// ^FT348,73^FH^A@N,39,38,E:ANMDS.TTF^FH\^FN13"Vendor Name"^FS /// ^BY2,4^FT643,376^B7N,4,0,2,2,N^FH\^FDSerial Number^FS /// ^FO5,17^GB863,379,8^FS /// ^XZ 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, "东风伟世通汽车饰件系统有限公司" }, // Customer Name { 11, "订单号" }, // Invoice Number { 13, "供应商名称" } // Vendor Name }; 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(); } } }
using Android.App; using Android.OS; using Android.Views; using Android.Widget; using System; using System.Collections.Generic; using System.Threading.Tasks; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; public class FormatUtilExample: Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout layout = (LinearLayout)View.Inflate(this, Android.Resource.Layout.ActivityListItem, null); layout.Orientation = Orientation.Vertical; Button buttonPrint = new Button(this) { Text = "Run Format Util Example", LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) }; layout.AddView(buttonPrint); SetContentView(layout); buttonPrint.Click += async (sender, e) => { await Task.Run(() => { string ipAddress = "1.2.3.4"; Example1(ipAddress); Example2(ipAddress); Example3(ipAddress); }); }; } /// Print a stored format with the given variables. This ZPL will store a format on a printer, for use with example1. /// /// ^XA /// ^DFE:FORMAT1.ZPL /// ^FS /// ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS /// ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS /// ^FT258,73^A0N,39,38^FH\^FDVisitor^FS /// ^BY2,4^FT403,376^B7N,4,0,2,2,N^FH^FDSerial Number^FS /// ^FO5,17^GB601,379,8^FS /// ^XZ private void Example1(string ipAddress) { Connection connection = new TcpConnection(ipAddress, 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(); } } /// Print a stored format with the given variables. This ZPL will store a format on the Link-OS™ printer, /// for use with Example2. /// /// ^XA /// ^DFE:FORMAT2.ZPL /// ^FS /// ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS /// ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS /// ^FT258,73^A0N,39,38^FH\^FDVisitor^FS /// ^FO100,100^XG^FN13,1,1^FS /// ^FO5,17^GB601,379,8^FS /// ^XZ private void Example2(string ipAddress) { Connection connection = new TcpConnection(ipAddress, 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(); } } /// Print a stored format with the given variables. This ZPL will store a format on a printer, for use with example3. /// This example also requires the ANMDS.TTF font to have been download to the printer prior to using this code. /// /// ^XA^DFE:FORMAT3.ZPL /// ^FS /// ^FT26,223^FH^A@N,56,55,E:ANMDS.TTF^CI28^FH\^FN12"Customer Name"^FS /// ^FT26,316^FH\^A@N,56,55,E:ANMDS.TTF^FH\^FN11"Invoice Number"^FS /// ^FT348,73^FH^A@N,39,38,E:ANMDS.TTF^FH\^FN13"Vendor Name"^FS /// ^BY2,4^FT643,376^B7N,4,0,2,2,N^FH\^FDSerial Number^FS /// ^FO5,17^GB863,379,8^FS /// ^XZ private void Example3(string ipAddress) { Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection); Dictionary<int, string> vars = new Dictionary<int, string> { { 12, "东风伟世通汽车饰件系统有限公司" }, // Customer Name { 11, "订单号" }, // Invoice Number { 13, "供应商名称" } // Vendor Name }; 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(); } } }
using CoreGraphics; using System; using System.Collections.Generic; using System.Threading.Tasks; using UIKit; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; public class FormatUtilExample : UIViewController { public FormatUtilExample(IntPtr handle) : base(handle) { UIButton testButton = new UIButton(UIButtonType.System) { Frame = new CGRect(25, 25, 300, 150) }; testButton.SetTitle("Run Format Util Example", UIControlState.Normal); testButton.TouchUpInside += async (sender, e) => { await Task.Run(() => { string ipAddress = "1.2.3.4"; Example1(ipAddress); Example2(ipAddress); Example3(ipAddress); }); }; View.AddSubview(testButton); } /// Print a stored format with the given variables. This ZPL will store a format on a printer, for use with example1. /// /// ^XA /// ^DFE:FORMAT1.ZPL /// ^FS /// ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS /// ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS /// ^FT258,73^A0N,39,38^FH\^FDVisitor^FS /// ^BY2,4^FT403,376^B7N,4,0,2,2,N^FH^FDSerial Number^FS /// ^FO5,17^GB601,379,8^FS /// ^XZ private void Example1(string ipAddress) { Connection connection = new TcpConnection(ipAddress, 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(); } } /// Print a stored format with the given variables. This ZPL will store a format on the Link-OS™ printer, /// for use with Example2. /// /// ^XA /// ^DFE:FORMAT2.ZPL /// ^FS /// ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS /// ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS /// ^FT258,73^A0N,39,38^FH\^FDVisitor^FS /// ^FO100,100^XG^FN13,1,1^FS /// ^FO5,17^GB601,379,8^FS /// ^XZ private void Example2(string ipAddress) { Connection connection = new TcpConnection(ipAddress, 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(); } } /// Print a stored format with the given variables. This ZPL will store a format on a printer, for use with example3. /// This example also requires the ANMDS.TTF font to have been download to the printer prior to using this code. /// /// ^XA^DFE:FORMAT3.ZPL /// ^FS /// ^FT26,223^FH^A@N,56,55,E:ANMDS.TTF^CI28^FH\^FN12"Customer Name"^FS /// ^FT26,316^FH\^A@N,56,55,E:ANMDS.TTF^FH\^FN11"Invoice Number"^FS /// ^FT348,73^FH^A@N,39,38,E:ANMDS.TTF^FH\^FN13"Vendor Name"^FS /// ^BY2,4^FT643,376^B7N,4,0,2,2,N^FH\^FDSerial Number^FS /// ^FO5,17^GB863,379,8^FS /// ^XZ private void Example3(string ipAddress) { Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection); Dictionary<int, string> vars = new Dictionary<int, string> { { 12, "东风伟世通汽车饰件系统有限公司" }, // Customer Name { 11, "订单号" }, // Invoice Number { 13, "供应商名称" } // Vendor Name }; 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(); } } }