Package com.zebra.sdk.printer
Class PrinterStatus
Object
com.zebra.sdk.printer.PrinterStatus
A class used to obtain the status of a Zebra printer.
package test.zebra.sdk.printer.examples;
import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.printer.PrinterStatus;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
public class PrinterStatusExample {
public static void main(String[] args) throws Exception {
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) {
System.out.println("Ready To Print");
} else if (printerStatus.isPaused) {
System.out.println("Cannot Print because the printer is paused.");
} else if (printerStatus.isHeadOpen) {
System.out.println("Cannot Print because the printer head is open.");
} else if (printerStatus.isPaperOut) {
System.out.println("Cannot Print because the paper is out.");
} else {
System.out.println("Cannot Print.");
}
} catch (ConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleantrueif the head is cold.booleantrueif the head is open.booleantrueif the head is too hot.booleantrueif the paper is out.booleantrueif there is a partial format in progress.booleantrueif the printer is paused.booleantrueif the printer reports back that it is ready to printbooleantrueif the receive buffer is full.booleantrueif the ribbon is out.intThe length of the label in dots.intThe number of labels remaining in the batch.intThe number of formats currently in the receive buffer of the printer.The print mode. -
Constructor Summary
ConstructorsConstructorDescriptionPrinterStatus(Connection printerConnection) Constructs a PrinterStatus instance that can be used to determine the status of a printer. -
Method Summary
-
Field Details
-
printMode
The print mode. For CPCL printers this is alwaysZplPrintMode.UNKNOWN -
labelLengthInDots
public int labelLengthInDotsThe length of the label in dots. For CPCL printers this is always 0 -
numberOfFormatsInReceiveBuffer
public int numberOfFormatsInReceiveBufferThe number of formats currently in the receive buffer of the printer. For CPCL printers this is always 0 -
labelsRemainingInBatch
public int labelsRemainingInBatchThe number of labels remaining in the batch. For CPCL printers this is always 0 -
isPartialFormatInProgress
public boolean isPartialFormatInProgresstrueif there is a partial format in progress. For CPCL printers this is alwaysfalse -
isHeadCold
public boolean isHeadColdtrueif the head is cold. For CPCL printers this is alwaysfalse -
isHeadOpen
public boolean isHeadOpentrueif the head is open. -
isHeadTooHot
public boolean isHeadTooHottrueif the head is too hot. For CPCL printers this is alwaysfalse -
isPaperOut
public boolean isPaperOuttrueif the paper is out. -
isRibbonOut
public boolean isRibbonOuttrueif the ribbon is out. -
isReceiveBufferFull
public boolean isReceiveBufferFulltrueif the receive buffer is full. For CPCL printers this is alwaysfalse -
isPaused
public boolean isPausedtrueif the printer is paused. For CPCL printers this is alwaysfalse -
isReadyToPrint
public boolean isReadyToPrinttrueif the printer reports back that it is ready to print
-
-
Constructor Details
-
PrinterStatus
Constructs a PrinterStatus instance that can be used to determine the status of a printer.
Note: this will only query the printer's status upon creation. If the status needs to be updated seeZebraPrinter.getCurrentStatus()- Parameters:
printerConnection- connection to the target printer- Throws:
ConnectionException- if an I/O error occurs
-