Package com.zebra.sdk.printer
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 TypeMethodDescriptionvoidSends the appropriate calibrate command to the printer.voidSends the appropriate print configuration command to the printer.voidreset()Sends the appropriate reset command to the printer.voidSends the appropriate restore defaults command to the printer.voidsendCommand(String command) Converts the specified command to bytes using the Java default charset and sends the bytes to the printer.voidsendCommand(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
Sends the appropriate calibrate command to the printer.- Throws:
ConnectionException- if an I/O error occurs.
-
restoreDefaults
Sends the appropriate restore defaults command to the printer.- Throws:
ConnectionException- if an I/O error occurs.
-
printConfigurationLabel
Sends the appropriate print configuration command to the printer.- Throws:
ConnectionException- if an I/O error occurs.
-
sendCommand
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
Sends the appropriate reset command to the printer.
Note: You should callConnection.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(); } } }
-