Click or drag to resize

FormatUtilLinkOs Interface

Defines functions used for interacting with Link-OS™ printer formats.

Namespace:  Zebra.Sdk.Printer
Assembly:  SdkApi.Core (in SdkApi.Core.dll) Version: 2.15.2634
Syntax
public interface FormatUtilLinkOs
Methods
  NameDescription
Public methodPrintStoredFormatWithVarGraphics(String, DictionaryInt32, String)
Prints a stored format on the printer, filling in the fields specified by the Dictionary.
Public methodPrintStoredFormatWithVarGraphics(String, DictionaryInt32, String, String)
Prints a stored format on the printer, filling in the fields specified by the Dictionary.
Public methodPrintStoredFormatWithVarGraphics(String, DictionaryInt32, ZebraImageI, DictionaryInt32, String)
Prints a stored format on the printer, filling in the fields specified by the Dictionaries.
Public methodPrintStoredFormatWithVarGraphics(String, DictionaryInt32, ZebraImageI, DictionaryInt32, String, String)
Prints a stored format on the printer, filling in the fields specified by the Dictionaries.
Top
Examples
Desktop
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();
        }
    }
}
Examples
Android™
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();
        }
    }
}
Examples
iOS
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();
        }
    }
}
See Also