Package com.zebra.sdk.printer
Interface ZebraPrinter
- All Superinterfaces:
FileUtil,FormatUtil,GraphicsUtil,ToolsUtil
- All Known Subinterfaces:
ZebraPrinterLinkOs
An interface used to obtain various properties 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.PrinterLanguage;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
public class ZebraPrinterExample {
public static void main(String[] args) throws Exception {
Connection connection = new TcpConnection("10.0.1.18", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.open();
ZebraPrinter zPrinter = ZebraPrinterFactory.getInstance(connection);
PrinterLanguage pcLanguage = zPrinter.getPrinterControlLanguage();
System.out.println("Printer Control Language is " + pcLanguage);
connection.close();
} catch (ConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
}
-
Method Summary
Modifier and TypeMethodDescriptionReturns the printer's connection.Returns a new instance ofPrinterStatusthat can be used to determine the status of a printer.Returns the printer control language (e.g. ZPL or CPCL) of the printer.voidsetConnection(Connection newConnection) Changes the printer's connection.Methods inherited from interface com.zebra.sdk.device.FileUtil
retrieveFileNames, retrieveFileNames, retrieveObjectsProperties, sendFileContents, sendFileContentsMethods inherited from interface com.zebra.sdk.printer.FormatUtil
getVariableFields, printStoredFormat, printStoredFormat, printStoredFormat, printStoredFormat, retrieveFormatFromPrinter, retrieveFormatFromPrinterMethods inherited from interface com.zebra.sdk.printer.GraphicsUtil
printImage, printImage, printImage, storeImage, storeImageMethods inherited from interface com.zebra.sdk.printer.ToolsUtil
calibrate, printConfigurationLabel, reset, restoreDefaults, sendCommand, sendCommand
-
Method Details
-
getPrinterControlLanguage
PrinterLanguage getPrinterControlLanguage()Returns the printer control language (e.g. ZPL or CPCL) of the printer.- Returns:
- the printer control language.
- See Also:
-
getCurrentStatus
Returns a new instance ofPrinterStatusthat can be used to determine the status of a printer. Each invocation of this method will result in a query of the connected printer. If more than one status value is to be read, it is recommended that a copy ofPrinterStatusis stored locally.
Note: This method must be invoked again to retrieve the most up-to-date status of the printer. ThePrinterStatusobject will only query the printer upon creation.
Note: Some Mobile printers (including the MZ series printers) will not communicate if the printer is not ready to print. On these printers, status information is not available when, for example, the printer is out of paper. This method will throw aConnectionExceptionif it is called when the printer cannot communicate.- Returns:
- a new instance of
PrinterStatus. - Throws:
ConnectionException- if there is an issue communicating with the printer (e.g. the connection is not open.)- See Also:
-
getConnection
Connection getConnection()Returns the printer's connection.- Returns:
- the printer's connection
-
setConnection
Changes the printer's connection.- Parameters:
newConnection- The new connection to be used for communication with the printer.
-