Click or drag to resize

GraphicsUtil Interface

This is an utility class for printing images on a device.

Namespace:  Zebra.Sdk.Printer
Assembly:  SdkApi.Core (in SdkApi.Core.dll) Version: 2.15.2634
Syntax
public interface GraphicsUtil
Methods
  NameDescription
Public methodPrintImage(String, Int32, Int32)
Prints an image from the connecting device file system to the connected device as a monochrome image.
Public methodPrintImage(String, Int32, Int32, Int32, Int32, Boolean)
Prints an image from the connecting device file system to the connected device as a monochrome image.
Public methodPrintImage(ZebraImageI, Int32, Int32, Int32, Int32, Boolean)
Prints an image to the connected device as a monochrome image.
Public methodStoreImage(String, String, Int32, Int32)
Stores the specified image to the connected printer as a monochrome image.
Public methodStoreImage(String, ZebraImageI, Int32, Int32)
Stores the specified image to the connected printer as a monochrome image.
Top
Examples
Desktop
using System;
using System.IO;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Printer;

public class GraphicsUtilExample {

    public static void Main(string[] args) {
        Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
        try {
            connection.Open();
            ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);

            int x = 0;
            int y = 0;
            printer.PrintImage("/path/to/my/image/sample.jpg", x, y);
        } 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.Threading;
using System.Threading.Tasks;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Printer;

public class GraphicsUtilExample: 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 Graphics 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";
                PrintImage(ipAddress);
            });
        };
    }

    public void PrintImage(string ipAddress) {
        Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT);
        try {
            connection.Open();
            ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);

            int x = 0;
            int y = 0;
            printer.PrintImage("/path/to/my/image/sample.jpg", x, y);
            Thread.Sleep(1000);
        } catch (ConnectionException e) {
            Console.WriteLine(e.ToString());
        } catch (ZebraPrinterLanguageUnknownException e) {
            Console.WriteLine(e.ToString());
        } catch (Exception e) {
            Console.WriteLine(e.ToString());
        } finally {
            connection.Close();
        }
    }
}
Examples
iOS
using CoreGraphics;
using System;
using System.Threading;
using System.Threading.Tasks;
using UIKit;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Printer;

public class GraphicsUtilExample : UIViewController {

    public GraphicsUtilExample(IntPtr handle) : base(handle) {
        UIButton testButton = new UIButton(UIButtonType.System) {
            Frame = new CGRect(25, 25, 300, 150)
        };

        testButton.SetTitle("Run Graphics Util Example", UIControlState.Normal);

        testButton.TouchUpInside += async (sender, e) => {
            await Task.Run(() => {
                string ipAddress = "1.2.3.4";
                PrintImage(ipAddress);
            });
        };

        View.AddSubview(testButton);
    }

    public void PrintImage(string ipAddress) {
        Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT);
        try {
            connection.Open();
            ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);

            int x = 0;
            int y = 0;
            printer.PrintImage("/path/to/my/image/sample.jpg", x, y);
            Thread.Sleep(1000);
        } catch (ConnectionException e) {
            Console.WriteLine(e.ToString());
        } catch (ZebraPrinterLanguageUnknownException e) {
            Console.WriteLine(e.ToString());
        } catch (Exception e) {
            Console.WriteLine(e.ToString());
        } finally {
            connection.Close();
        }
    }
}
See Also