FormatUtilLinkOs Interface |
Namespace: Zebra.Sdk.Printer
Name | Description | |
---|---|---|
PrintStoredFormatWithVarGraphics(String, DictionaryInt32, String) |
Prints a stored format on the printer, filling in the fields specified by the Dictionary.
| |
PrintStoredFormatWithVarGraphics(String, DictionaryInt32, String, String) |
Prints a stored format on the printer, filling in the fields specified by the Dictionary.
| |
PrintStoredFormatWithVarGraphics(String, DictionaryInt32, ZebraImageI, DictionaryInt32, String) |
Prints a stored format on the printer, filling in the fields specified by the Dictionaries.
| |
PrintStoredFormatWithVarGraphics(String, DictionaryInt32, ZebraImageI, DictionaryInt32, String, String) |
Prints a stored format on the printer, filling in the fields specified by the Dictionaries.
|
using System; using System.Collections.Generic; using System.IO; using Zebra.Sdk.Comm; using Zebra.Sdk.Graphics; using Zebra.Sdk.Printer; public class FormatUtilLinkOsExample { /// Print a stored format with the given variables. /// /// The following ZPL will store a format on the Link-OS™ printer. /// /// ^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 public static void Main(string[] args) { string pathToImageFileOnHost = "/path/to/my/image/example.png"; Connection connection = new TcpConnection("1.2.3.4", TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); Dictionary<int, string> vars = new Dictionary<int, string> { { 12, "John" }, { 11, "Smith" } }; ZebraImageI image = ZebraImageFactory.GetImage(pathToImageFileOnHost); Dictionary<int, ZebraImageI> imgVars = new Dictionary<int, ZebraImageI> { { 13, image } }; ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (linkOsPrinter != null) { linkOsPrinter.PrintStoredFormatWithVarGraphics("E:FORMAT2.ZPL", imgVars, vars); } } catch (ConnectionException e) { Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine(e.ToString()); } catch (IOException 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.IO; using System.Threading.Tasks; using Zebra.Sdk.Comm; using Zebra.Sdk.Graphics; using Zebra.Sdk.Printer; public class FormatUtilLinkOsExample : 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"; PrintStoredFormat(ipAddress); }); }; } /// Print a stored format with the given variables. /// /// The following ZPL will store a format on the Link-OS™ printer. /// /// ^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 public void PrintStoredFormat(string ipAddress) { string pathToImageFileOnHost = "/path/to/my/image/example.png"; Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); Dictionary<int, string> vars = new Dictionary<int, string> { { 12, "John" }, { 11, "Smith" } }; ZebraImageI image = ZebraImageFactory.GetImage(pathToImageFileOnHost); Dictionary<int, ZebraImageI> imgVars = new Dictionary<int, ZebraImageI> { { 13, image } }; ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (linkOsPrinter != null) { linkOsPrinter.PrintStoredFormatWithVarGraphics("E:FORMAT2.ZPL", imgVars, vars); } } catch (ConnectionException e) { Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine(e.ToString()); } catch (IOException e) { Console.WriteLine(e.ToString()); } finally { connection.Close(); } } }
using CoreGraphics; using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using UIKit; using Zebra.Sdk.Comm; using Zebra.Sdk.Graphics; using Zebra.Sdk.Printer; public class FormatUtilLinkOsExample : UIViewController { public FormatUtilLinkOsExample(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"; PrintStoredFormat(ipAddress); }); }; View.AddSubview(testButton); } /// Print a stored format with the given variables. /// /// The following ZPL will store a format on the Link-OS™ printer. /// /// ^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 public void PrintStoredFormat(string ipAddress) { string pathToImageFileOnHost = "/path/to/my/image/example.png"; Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); Dictionary<int, string> vars = new Dictionary<int, string> { { 12, "John" }, { 11, "Smith" } }; ZebraImageI image = ZebraImageFactory.GetImage(pathToImageFileOnHost); Dictionary<int, ZebraImageI> imgVars = new Dictionary<int, ZebraImageI> { { 13, image } }; ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(connection); ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter); if (linkOsPrinter != null) { linkOsPrinter.PrintStoredFormatWithVarGraphics("E:FORMAT2.ZPL", imgVars, vars); } } catch (ConnectionException e) { Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine(e.ToString()); } catch (IOException e) { Console.WriteLine(e.ToString()); } finally { connection.Close(); } } }