Interface ToolsUtil

All Known Subinterfaces:
ZebraPrinter, ZebraPrinterLinkOs

public interface ToolsUtil
This is a utility class for performing printer actions. (Restore defaults, calibrate, etc.)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Sends the appropriate calibrate command to the printer.
    void
    Sends the appropriate print configuration command to the printer.
    void
    Sends the appropriate reset command to the printer.
    void
    Sends the appropriate restore defaults command to the printer.
    void
    Converts the specified command to bytes using the Java default charset and sends the bytes to the printer.
    void
    sendCommand(String command, String encoding)
    Converts the specified command to bytes using the specified charset "encoding" and sends the bytes to the printer.
  • Method Details

    • calibrate

      void calibrate() throws ConnectionException
      Sends the appropriate calibrate command to the printer.
      Throws:
      ConnectionException - if an I/O error occurs.
    • restoreDefaults

      void restoreDefaults() throws ConnectionException
      Sends the appropriate restore defaults command to the printer.
      Throws:
      ConnectionException - if an I/O error occurs.
    • printConfigurationLabel

      void printConfigurationLabel() throws ConnectionException
      Sends the appropriate print configuration command to the printer.
      Throws:
      ConnectionException - if an I/O error occurs.
    • sendCommand

      void sendCommand(String command) throws ConnectionException
      Converts the specified command to bytes using the Java default charset and sends the bytes to the printer.
      Parameters:
      command - the command to send to the printer.
      Throws:
      ConnectionException - if an I/O error occurs.
    • sendCommand

      void sendCommand(String command, String encoding) throws ConnectionException, UnsupportedEncodingException
      Converts the specified command to bytes using the specified charset "encoding" and sends the bytes to the printer.
      Parameters:
      command - the command to send to the printer.
      encoding - a character-encoding name (eg. UTF-8).
      Throws:
      ConnectionException - if an I/O error occurs.
      UnsupportedEncodingException - if the encoding is not supported.
    • reset

      void reset() throws ConnectionException
      Sends the appropriate reset command to the printer.
      Note: You should call Connection.close() after this method, as resetting the printer will terminate the connection.
      Throws:
      ConnectionException - if an I/O error occurs.
      
      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.ZebraPrinter;
       import com.zebra.sdk.printer.ZebraPrinterFactory;
       import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
       
       public class ToolsUtilExample {
       
           public static void main(String[] args) throws Exception {
               Connection connection = new TcpConnection("192.168.1.101", TcpConnection.DEFAULT_ZPL_TCP_PORT);
               try {
                   connection.open();
                   ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
                   printer.reset();
               } catch (ConnectionException e) {
                   e.printStackTrace();
               } catch (ZebraPrinterLanguageUnknownException e1) {
                   e1.printStackTrace();
               } finally {
                   connection.close();
               }
           }
       }