PrinterStatus Class |
Namespace: Zebra.Sdk.Printer
The PrinterStatus type exposes the following members.
Name | Description | |
---|---|---|
PrinterStatus |
Constructs a PrinterStatus instance that can be used to determine the status of a printer.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
isHeadCold | true if the head is cold. For CPCL printers this is always false | |
isHeadOpen | true if the head is open.
| |
isHeadTooHot | true if the head is too hot. For CPCL printers this is always false | |
isPaperOut | true if the paper is out.
| |
isPartialFormatInProgress | true if there is a partial format in progress. For CPCL printers this is always false.
| |
isPaused | true if the printer is paused. For CPCL printers this is always false | |
isReadyToPrint | true if the printer reports back that it is ready to print
| |
isReceiveBufferFull | true if the receive buffer is full. For CPCL printers this is always false | |
isRibbonOut | true if the ribbon is out.
| |
labelLengthInDots |
The length of the label in dots. For CPCL printers this is always 0.
| |
labelsRemainingInBatch |
The number of labels remaining in the batch. For CPCL printers this is always 0.
| |
numberOfFormatsInReceiveBuffer |
The number of formats currently in the receive buffer of the printer. For CPCL printers this is always 0.
| |
printMode |
The print mode. For CPCL printers this is always UNKNOWN |
using System; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; public class PrinterStatusExample { public static void Main(string[] args) { Connection connection = new TcpConnection("192.168.1.100", TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection); PrinterStatus printerStatus = printer.GetCurrentStatus(); if (printerStatus.isReadyToPrint) { Console.WriteLine("Ready To Print"); } else if (printerStatus.isPaused) { Console.WriteLine("Cannot Print because the printer is paused."); } else if (printerStatus.isHeadOpen) { Console.WriteLine("Cannot Print because the printer head is open."); } else if (printerStatus.isPaperOut) { Console.WriteLine("Cannot Print because the paper is out."); } else { Console.WriteLine("Cannot Print."); } } 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.Threading.Tasks; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; public class PrinterStatusExample : 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 testButton = new Button(this) { Text = "Get Printer Status", LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) }; layout.AddView(testButton); SetContentView(layout); testButton.Click += async (sender, e) => { await Task.Run(() => { string ipAddress = "1.2.3.4"; GetPrinterStatus(ipAddress); }); }; } public void GetPrinterStatus(string ipAddress) { Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection); PrinterStatus printerStatus = printer.GetCurrentStatus(); string status = ""; if (printerStatus.isReadyToPrint) { status = "Ready To Print"; } else if (printerStatus.isPaused) { status = "Cannot Print because the printer is paused."; } else if (printerStatus.isHeadOpen) { status = "Cannot Print because the printer head is open."; } else if (printerStatus.isPaperOut) { status = "Cannot Print because the paper is out."; } else { status = "Cannot Print."; } RunOnUiThread(() => { Toast.MakeText(ApplicationContext, $"Printer status: {status}", ToastLength.Long).Show(); }); } catch (ConnectionException e) { Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine(e.ToString()); } finally { connection.Close(); } } }
using CoreGraphics; using System; using System.Threading.Tasks; using UIKit; using Zebra.Sdk.Comm; using Zebra.Sdk.Printer; public class PrinterStatusExample : UIViewController { public PrinterStatusExample(IntPtr handle) : base(handle) { UIButton testButton = new UIButton(UIButtonType.System) { Frame = new CGRect(25, 25, 300, 150) }; testButton.SetTitle("Get Printer Status", UIControlState.Normal); testButton.TouchUpInside += async (sender, e) => { await Task.Run(() => { string ipAddress = "1.2.3.4"; GetPrinterStatus(ipAddress); }); }; View.AddSubview(testButton); } public void GetPrinterStatus(string ipAddress) { Connection connection = new TcpConnection(ipAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT); try { connection.Open(); ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection); PrinterStatus printerStatus = printer.GetCurrentStatus(); string status = ""; if (printerStatus.isReadyToPrint) { status = "Ready To Print"; } else if (printerStatus.isPaused) { status = "Cannot Print because the printer is paused."; } else if (printerStatus.isHeadOpen) { status = "Cannot Print because the printer head is open."; } else if (printerStatus.isPaperOut) { status = "Cannot Print because the paper is out."; } else { status = "Cannot Print."; } ShowAlertMessage("GetPrinterStatus", $"Printer Status: {status}"); } catch (ConnectionException e) { Console.WriteLine(e.ToString()); } catch (ZebraPrinterLanguageUnknownException e) { Console.WriteLine(e.ToString()); } finally { connection.Close(); } } private void ShowAlertMessage(string title, string message) { InvokeOnMainThread(() => { UIAlertController alertController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alertController, true, null); }); } }