public class PrinterUtil
extends Object
Modifier and Type | Method and Description |
---|---|
static void |
convertGraphic(String filePathOnPrinter,
ZebraImageI image,
int width,
int height,
java.io.OutputStream convertedGraphicOutputStream)
Encodes supplied image in either ZPL or CPCL after dithering and resizing.
|
static void |
convertGraphic(String filePathOnPrinter,
ZebraImageI image,
java.io.OutputStream convertedGraphicOutputStream)
Encodes supplied image in either ZPL or CPCL after dithering and resizing.
|
static void |
createBackup(String connectionString,
String profilePath)
Create a backup of your printer's settings, alerts, and files.
|
static void |
createProfile(String connectionString,
String profilePath)
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
|
static void |
deleteFile(String connectionString,
String filePath)
Deletes file(s) from the printer.
|
static String[] |
deleteFileReportDeleted(String connectionString,
String filePath)
Deletes file(s) from the printer and reports what files were actually removed.
|
static PrinterStatus |
getCurrentStatus(Connection printerConnection,
PrinterLanguage language)
Returns a new instance of
PrinterStatus that can be used to determine the status of a printer. |
static void |
getObjectFromPrinter(java.io.OutputStream destinationStream,
String connectionString,
String filePathOnPrinter)
Retrieves a file from the printer's file system and writes the contents of that file to an output stream.
|
static byte[] |
getObjectFromPrinter(String connectionString,
String filePathOnPrinter)
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
|
static void |
getObjectFromPrinterViaFtp(java.io.OutputStream destination,
String connectionString,
String filePathOnPrinter,
String ftpPassword)
Retrieves a file from the printer's file system via FTP and writes the contents of that file to an output stream.
|
static byte[] |
getObjectFromPrinterViaFtp(String connectionString,
String filePathOnPrinter,
String ftpPassword)
Retrieves a file from the printer's file system via FTP and returns the contents of that file as a byte[].
|
static java.util.List<String> |
getOdometerStatus(String connectionString)
Retrieves status of the printer odometer which includes the total print length, head clean counter, label dot
length, head new, latch open counter, and both user resettable counters.
See ConnectionBuilder for the format of connectionString . |
static java.util.List<TcpPortStatus> |
getPortStatus(String connectionString)
Retrieves a list of currently open tcp ports on the printer.
See ConnectionBuilder for the format of connectionString . |
static java.util.List<String> |
getPrinterStatus(String connectionString)
Retrieves status of the printer which includes any error messages currently set along with the number of labels
remaining in queue, number of labels remaining in batch, and whether or not a label is currently being processed.
|
static java.util.Map<String,Setting> |
getSettingsFromPrinter(String connectionString)
Retrieve all settings and their attributes from the specified printer.
See ConnectionBuilder for the format of connectionString . |
static String[] |
listFiles(String connectionString,
String filter)
Retrieves the names of the files which are stored on the device.
See ConnectionBuilder for the format of connectionString . |
static void |
loadBackup(String connectionString,
String backupPath)
Takes settings, alerts, and files from a backup, and applies them to a printer.
|
static void |
loadBackup(String connectionString,
String backupPath,
boolean isVerbose)
Takes settings, alerts, and files from a backup, and applies them to a printer.
|
static void |
loadProfile(String connectionString,
String profilePath,
FileDeletionOption filesToDelete)
Takes settings, alerts, and files from a profile, and applies them to a printer.
|
static void |
loadProfile(String connectionString,
String profilePath,
FileDeletionOption filesToDelete,
boolean isVerbose)
Takes settings, alerts, and files from a profile, and applies them to a printer.
|
static void |
printConfigLabel(String connectionString)
Causes the specified printer to print a configuration label.
See ConnectionBuilder for the format of connectionString . |
static void |
printDirectoryLabel(String connectionString)
Causes the specified printer to print a directory listing of all the files saved on the printer.
See ConnectionBuilder for the format of connectionString . |
static void |
printNetworkConfigLabel(String connectionString)
Causes the specified printer to print a network configuration label.
See ConnectionBuilder for the format of connectionString . |
static String |
quickStatus(String connectionString)
Retrieves the quick status of the printer.
See ConnectionBuilder for the format of connectionString . |
static void |
resetNetwork(String connectionString)
Resets the network of the specified printer.
|
static void |
resetPrinter(String connectionString)
|
static void |
restoreNetworkDefaults(String connectionString)
Restores the printer's network settings to their factory default configuration.
|
static void |
restorePrinterDefaults(String connectionString)
Restores the printer's settings to their factory default configuration.
See ConnectionBuilder for the format of connectionString . |
static void |
sendContents(String connectionString,
java.io.InputStream data)
Send contents of
data directly to the device specified via connectionString using UTF-8
encoding.See ConnectionBuilder for the format of connectionString . |
static void |
sendContents(String connectionString,
java.io.InputStream data,
String encoding)
Send contents of
data directly to the device specified via connectionString using
encoding .See ConnectionBuilder for the format of connectionString . |
static void |
sendContents(String connectionString,
String data)
Send contents of
data directly to the device specified via connectionString using UTF-8
encoding. |
static void |
sendContents(String connectionString,
String data,
String encoding)
Send contents of
data directly to the device specified via connectionString using
encoding .See ConnectionBuilder for the format of connectionString . |
static void |
sendJSON(String connectionString,
java.io.InputStream data,
String encoding)
Send contents of
data directly to the device specified via connectionString using
encoding .See ConnectionBuilder for the format of connectionString . |
static void |
setClock(String connectionString,
String dateTime)
|
static void |
storeFile(String connectionString,
String filePath,
String remoteName)
Stores the file on the printer at the specified location and name using any required file wrappers.
See ConnectionBuilder for the format of connectionString . |
static void |
updateFirmware(String connection,
String firmwareFilePath,
long timeout)
Update the printer firmware.
|
public static void sendContents(String connectionString, String data) throws ConnectionException, java.io.IOException
data
directly to the device specified via connectionString
using UTF-8
encoding. connectionString
.connectionString
- The connection string.data
- Data to send to the printer.java.io.IOException
- if there is an error encoding data
.ConnectionException
- if there is an error communicating with the printer.public static void sendContents(String connectionString, String data, String encoding) throws ConnectionException, java.io.IOException
data
directly to the device specified via connectionString
using
encoding
.connectionString
.connectionString
- The connection string.data
- Data to send to the printer.encoding
- A character-encoding name (eg. UTF-8).ConnectionException
- if there is an error communicating with the printer.java.io.IOException
- if there is an error encoding data
.public static void sendContents(String connectionString, java.io.InputStream data) throws ConnectionException, java.io.IOException
data
directly to the device specified via connectionString
using UTF-8
encoding.connectionString
.connectionString
- The connection string.data
- Data to send to the printer.ConnectionException
- if there is an error communicating with the printer.java.io.IOException
- if there is an error reading from data
.public static void sendContents(String connectionString, java.io.InputStream data, String encoding) throws ConnectionException, java.io.IOException
data
directly to the device specified via connectionString
using
encoding
.connectionString
.connectionString
- The connection string.data
- Data to send to the printer.encoding
- A character-encoding name (eg. UTF-8).ConnectionException
- if there is an error communicating with the printer.java.io.IOException
- if there is an error reading from data
.public static void sendJSON(String connectionString, java.io.InputStream data, String encoding) throws ConnectionException, java.io.IOException
data
directly to the device specified via connectionString
using
encoding
.connectionString
.connectionString
- The connection string.data
- Data to send to the printer.encoding
- A character-encoding name (eg. UTF-8).ConnectionException
- if there is an error communicating with the printer.java.io.IOException
- if there is an error reading from data
.public static java.util.List<TcpPortStatus> getPortStatus(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static java.util.List<String> getOdometerStatus(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static java.util.List<String> getPrinterStatus(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static String quickStatus(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void setClock(String connectionString, String dateTime) throws ConnectionException, ZebraPrinterLanguageUnknownException, ZebraIllegalArgumentException, NotALinkOsPrinterException
connectionString
- The connection string.dateTime
- Format MM-dd-yyyy HH:mm:ssConnectionException
- if there is an error communicating with the printer.ZebraPrinterLanguageUnknownException
- if the printer language can not be determined.ZebraIllegalArgumentException
- if the format of dateTime
is invalid.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static String[] deleteFileReportDeleted(String connectionString, String filePath) throws ConnectionException, ZebraPrinterLanguageUnknownException, ZebraIllegalArgumentException, NotALinkOsPrinterException
filePath
may also
contain wildcards.connectionString
.connectionString
- The connection string. (May be null)filePath
- The location of the file on the printer. Wildcards are also accepted. (e.g. "E:FORMAT.ZPL",
"E:*.*")ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language cannot be determined.ZebraIllegalArgumentException
- if there is an error parsing the directory data returned by the device.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void deleteFile(String connectionString, String filePath) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
filePath
may also contain wildcards.connectionString
.connectionString
- The connection string. (May be null)filePath
- the location of the file on the printer. Wildcards are also accepted. (e.g. "E:FORMAT.ZPL",
"E:*.*")ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language cannot be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static String[] listFiles(String connectionString, String filter) throws ConnectionException, ZebraIllegalArgumentException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string. (May be null)filter
- Filter for returned files. (e.g. "E:*.ZPL", "*:*.*", "R:MYFILE.*")ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language cannot be determined.ZebraIllegalArgumentException
- if there is an error parsing the directory data returned by the device.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static byte[] getObjectFromPrinter(String connectionString, String filePathOnPrinter) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException, ZebraIllegalArgumentException
connectionString
.connectionString
- The connection string.filePathOnPrinter
- file to retrieve. (e.g. "R:MYFILE.PNG")ConnectionException
- if there is an error connecting to the device, or the ftp password is not correct.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ZebraIllegalArgumentException
- if the filename is invalid or does not exist.public static void getObjectFromPrinter(java.io.OutputStream destinationStream, String connectionString, String filePathOnPrinter) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException, ZebraIllegalArgumentException
connectionString
.destinationStream
- Stream to receive file contents.connectionString
- The connection string.filePathOnPrinter
- file to retrieve. (e.g. "R:MYFILE.PNG")ConnectionException
- if there is an error connecting to the device, or the ftp password is not correct.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ZebraIllegalArgumentException
- if the filename is invalid or does not exist.public static byte[] getObjectFromPrinterViaFtp(String connectionString, String filePathOnPrinter, String ftpPassword) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException, ZebraIllegalArgumentException
connectionString
.connectionString
- The connection string.filePathOnPrinter
- File to retrieve. (e.g. "R:MYFILE.PNG")ftpPassword
- Password to use for ftp, if null a default password will be used.ConnectionException
- if there is an error connecting to the device, or the ftp password is not correct.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ZebraIllegalArgumentException
- if the filename is invalid or does not exist.public static void getObjectFromPrinterViaFtp(java.io.OutputStream destination, String connectionString, String filePathOnPrinter, String ftpPassword) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException, ZebraIllegalArgumentException
connectionString
.destination
- Stream to receive the file contents.connectionString
- The connection string.filePathOnPrinter
- File to retrieve. (e.g. "R:MYFILE.PNG")ftpPassword
- password to use for ftp, if null a default password will be used.ConnectionException
- if there is an error connecting to the device, or the ftp password is not correct.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ZebraIllegalArgumentException
- if the filename is invalid or does not exist.public static void updateFirmware(String connection, String firmwareFilePath, long timeout) throws ConnectionException, ZebraPrinterLanguageUnknownException, ZebraIllegalArgumentException, DiscoveryException, java.util.concurrent.TimeoutException, java.io.FileNotFoundException
connection
.connection
- The connection string.firmwareFilePath
- File path of firmware file.timeout
- Timeout in milliseconds. The minimum allowed timeout is 5 minutes (300000ms) due to the need to
reset the printer after flashing the firmware. If a timeout value less than the minimum is provided, the minimum
will be used instead.ConnectionException
- if the connection can not be opened or is closed prematurely.ZebraPrinterLanguageUnknownException
- if the printer language can not be determined.ZebraIllegalArgumentException
- if an invalid firmware file is specified for the printer.DiscoveryException
- if an error occurs while waiting for the printer to come back online.java.util.concurrent.TimeoutException
- if the maximum timeout is reached prior to the printer coming back online with the new
firmware.java.io.FileNotFoundException
- if the firmware file cannot be found or cannot be opened.public static void convertGraphic(String filePathOnPrinter, ZebraImageI image, java.io.OutputStream convertedGraphicOutputStream) throws ZebraIllegalArgumentException, java.io.IOException
filePathOnPrinter
- The printer file path you wish to store the image to.image
- ZebraImage to be dithered and resized.convertedGraphicOutputStream
- OutputStream to store encoded image data.ZebraIllegalArgumentException
- if the file type is not supported or an invalid image is supplied.java.io.IOException
- Could not read/write to file.public static void convertGraphic(String filePathOnPrinter, ZebraImageI image, int width, int height, java.io.OutputStream convertedGraphicOutputStream) throws ZebraIllegalArgumentException, java.io.IOException
filePathOnPrinter
- The printer file path you wish to store the image to.image
- ZebraImage to be dithered and resized.width
- Width of the resulting image. If 0 the image is not resized.height
- Height of the resulting image. If 0 the image is not resized.convertedGraphicOutputStream
- OutputStream to store converted image data encoded with the printers native
language.ZebraIllegalArgumentException
- if the file type is not supported or an invalid image is supplied.java.io.IOException
- Could not read/write to file.public static void createProfile(String connectionString, String profilePath) throws java.io.IOException, ZebraIllegalArgumentException, ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.profilePath
- The location of where to store the profile.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue creating the profile.ZebraIllegalArgumentException
- Could not interpret the response from the printer.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ProfileUtil.createProfile(String)
public static void createBackup(String connectionString, String profilePath) throws ConnectionException, java.io.IOException, ZebraPrinterLanguageUnknownException, ZebraIllegalArgumentException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.profilePath
- The location of where to store the profile. The extension must be .zprofile; if it is not, the
method will change it to .zprofile for you.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue creating the profile.ZebraIllegalArgumentException
- Could not interpret the response from the printer.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ProfileUtil.createBackup(String)
public static void loadProfile(String connectionString, String profilePath, FileDeletionOption filesToDelete) throws ConnectionException, java.io.IOException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
filesToDelete
from the printer.connectionString
.connectionString
- The connection string.profilePath
- Path to the profile to load. (e.g. /home/user/profile.zprofile)filesToDelete
- An enum describing which files to delete.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue loading the profile.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void loadProfile(String connectionString, String profilePath, FileDeletionOption filesToDelete, boolean isVerbose) throws ConnectionException, java.io.IOException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
filesToDelete
from the printer.connectionString
.connectionString
- The connection string.profilePath
- Path to the profile to load. (e.g. /home/user/profile.zprofile)filesToDelete
- An enum describing which files to delete.isVerbose
- Increases the amount of detail presented to the user.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue loading the profile.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void loadBackup(String connectionString, String backupPath) throws ConnectionException, java.io.IOException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.backupPath
- Path to the profile to load. (e.g. /home/user/profile.zprofile)ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue loading the profile.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void loadBackup(String connectionString, String backupPath, boolean isVerbose) throws ConnectionException, java.io.IOException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.backupPath
- Path to the profile to load. (e.g. /home/user/profile.zprofile)isVerbose
- Increases the amount of detail presented to the user.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue loading the profile.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void storeFile(String connectionString, String filePath, String remoteName) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException, ZebraIllegalArgumentException, java.io.IOException
connectionString
.connectionString
- The connection string.filePath
- The path of the file to store.remoteName
- The path on the printer.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.java.io.IOException
- if there is an issue storing the file.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ZebraIllegalArgumentException
- if there is an issue storing the file.public static void resetPrinter(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
- The connection string.ConnectionException
- if there is an error connecting to the deviceZebraPrinterLanguageUnknownException
- if the printer language could not be determinedNotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void resetNetwork(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the deviceZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void restorePrinterDefaults(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void restoreNetworkDefaults(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void printConfigLabel(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void printNetworkConfigLabel(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static void printDirectoryLabel(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException
connectionString
.connectionString
- The connection string.ConnectionException
- if there is an error connecting to the device.ZebraPrinterLanguageUnknownException
- if the printer language could not be determined.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.public static java.util.Map<String,Setting> getSettingsFromPrinter(String connectionString) throws ConnectionException, ZebraPrinterLanguageUnknownException, NotALinkOsPrinterException, SettingsException
connectionString
.connectionString
- The connection string.NotALinkOsPrinterException
- This feature is only available on Link-OS printers.ZebraPrinterLanguageUnknownException
- if the printer language can not be determined.ConnectionException
- if there is an error connecting to the device.SettingsException
- if the settings could not be retrieved.public static PrinterStatus getCurrentStatus(Connection printerConnection, PrinterLanguage language) throws ConnectionException
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.PrinterStatus
object will only query the printer upon creation. ConnectionException
if it is called when the printer cannot communicate.printerConnection
- Connection to the printer.language
- Printer control language to be used.PrinterStatus
.ConnectionException
- if there is an issue communicating with the printer (e.g. the connection is not
open.)PrinterStatus
© 2017 ZIH Corp. All Rights Reserved.