Interface ZebraPrinter

All Superinterfaces:
FileUtil, FormatUtil, GraphicsUtil, ToolsUtil
All Known Subinterfaces:
ZebraPrinterLinkOs

public interface ZebraPrinter extends FileUtil, GraphicsUtil, FormatUtil, ToolsUtil
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 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

      PrinterStatus getCurrentStatus() throws ConnectionException
      Returns a new instance of PrinterStatus that 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 of PrinterStatus is stored locally.

      Note: This method must be invoked again to retrieve the most up-to-date status of the printer. The PrinterStatus object 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 a ConnectionException if 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

      void setConnection(Connection newConnection)
      Changes the printer's connection.
      Parameters:
      newConnection - The new connection to be used for communication with the printer.