Package com.zebra.sdk.device
Class Profile
Object
com.zebra.sdk.device.Profile
- All Implemented Interfaces:
Device,FileUtil,FileUtilLinkOs,AlertProvider,FontUtil,GraphicsUtil,SettingsProvider
public class Profile
extends Object
implements Device, FileUtil, FontUtil, AlertProvider, FileUtilLinkOs, GraphicsUtil
Interface to access the contents of a .zprofile file.
package test.zebra.sdk.device.examples;
import java.io.IOException;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.device.Profile;
import com.zebra.sdk.device.ZebraIllegalArgumentException;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLinkOs;
import com.zebra.sdk.settings.SettingsException;
public class ProfileExample {
public static void main(String[] args) throws Exception {
String pathToProfile = "C:\\MyNewProfile.zprofile";
String printerToClone = "1.2.3.4";
String targetPrinter = "192.168.1.33";
String darknessSettingId = "print.tone";
String newDarknessValue = "10.0";
TcpConnection connection = new TcpConnection(printerToClone, TcpConnection.DEFAULT_ZPL_TCP_PORT);
TcpConnection targetPrinterConnection = new TcpConnection(targetPrinter, TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.open();
ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.getLinkOsPrinter(connection);
if (linkOsPrinter != null) {
System.out.println("Start profile operation");
// Create a profile containing the settings from printerToClone.
linkOsPrinter.createProfile(pathToProfile);
System.out.println("Done");
}
connection.close();
// Change the darkness in the profile.
Profile profileForCloning = new Profile(pathToProfile);
if (profileForCloning.getAvailableSettings().contains(darknessSettingId) &&
profileForCloning.isSettingValid(darknessSettingId, newDarknessValue) &&
profileForCloning.isSettingReadOnly(darknessSettingId) == false) {
profileForCloning.setSetting(darknessSettingId, newDarknessValue);
}
targetPrinterConnection.open();
ZebraPrinterLinkOs linkOsTargetPrinter = ZebraPrinterFactory.getLinkOsPrinter(targetPrinterConnection);
if (linkOsTargetPrinter != null) {
System.out.println("Start cloning operation");
// Clone the profile to targetPrinter
linkOsTargetPrinter.loadProfile(pathToProfile);
System.out.println("Done");
}
} catch (ConnectionException e) {
System.out.println("Could not use connection");
e.printStackTrace();
} catch (ZebraIllegalArgumentException e) {
System.out.println("Unexpected response from Zebra printer");
e.printStackTrace();
} catch (IOException e) {
System.out.println("Could not write to " + pathToProfile);
e.printStackTrace();
} catch (SettingsException e) {
System.out.println("Could not access " + darknessSettingId);
e.printStackTrace();
} finally {
connection.close();
targetPrinterConnection.close();
}
}
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirmware(String pathToFirmwareFile) Adds a firmware file to an existing printer profile.voidaddFirmware(String firmwareFileName, byte[] firmwareFileContents) Adds a firmware file to an existing printer profile.voidaddSupplement(byte[] supplementData) Adds data to supplement an existing printer profile.voidconfigureAlert(PrinterAlert alert) Configures an alert to be triggered when the alert's condition occurs or becomes resolved.voidconfigureAlerts(List<PrinterAlert> alerts) Configures a list of alerts to be triggered when their conditions occur or become resolved.voiddeleteFile(String filePath) Deletes the file from the profile.voiddeleteFileOnPrinterProtected(String filePath, String authPassword) Deletes the file from the printer on protected mode.voiddownloadTteFont(InputStream sourceInputStream, String pathOnPrinter) Adds a TrueType® font to a profile and stores it at the specified path as a TrueType® extension (TTE).voiddownloadTteFont(String sourceFilePath, String pathOnPrinter) Adds a TrueType® font file to a profile and stores it at the specified path as a TrueType® extension (TTE).voiddownloadTtfFont(InputStream sourceInputStream, String pathOnPrinter) Adds a TrueType® font file to a profile and stores it at the specified path as a TTF.voiddownloadTtfFont(String sourceFilePath, String pathOnPrinter) Adds a TrueType® font file to a profile and stores it at the specified path as a TTF.Retrieve all settings and their attributes.Retrieves all of the profile's setting values.Retrieve the values of all the settings that are archivable.Retrieve all of the setting identifiers for a profile.Retrieve the values of all the settings that are clonable.A list of objects detailing the alert configurations in a profile.Returns the file name of the firmware file within the profile.voidgetObjectFromPrinter(OutputStream destinationStream, String filePath) Retrieves a file from the printer's file system and writes the contents of that file to destinationStream.byte[]getObjectFromPrinter(String filePath) Retrieves a file from the profile and returns the contents of that file as a byte array.voidgetObjectFromPrinterViaFtp(OutputStream destinationStream, String filePath, String ftpPassword) Retrieves a file from the printer's file system via FTP and writes the contents of that file to destinationStream.byte[]getObjectFromPrinterViaFtp(String filePath, String ftpPassword) This method is not valid for a profile.byte[]Retrieves a file from the profile and returns the contents of that file as a byte array including all necessary file wrappers for redownloading to a Zebra printer.getSetting(String settingId) Retrieves the profile'sSettingfor a setting id.getSettingRange(String settingId) Retrieves the allowable range for a setting.getSettingsValues(List<String> listOfSettings) Retrieves the profile's setting values for a list of setting ids.getSettingType(String settingId) Returns the data type of the setting.getSettingValue(String settingId) Retrieves the profile's setting value for a setting id.This method is not valid for a profile.Returns the supplement data within the profile.booleanisSettingReadOnly(String settingId) Returns true if the setting is read only.booleanisSettingValid(String settingId, String value) Returns true if value is valid for the given setting.booleanisSettingWriteOnly(String settingId) Returns true if the setting is write only.voidprintImage(ZebraImageI image, int x, int y, int width, int height, boolean insideFormat) Prints an image to the connected device as a monochrome image.voidprintImage(String imageFilePath, int x, int y) Prints an image from the connecting device file system to the connected device as a monochrome image.voidprintImage(String imageFilePath, int x, int y, int width, int height, boolean insideFormat) Prints an image from the connecting device file system to the connected device as a monochrome image.processSettingsViaMap(Map<String, String> settingValuePairs) Change or retrieve settings in the profile.voidremoveAlert(PrinterAlert alert) Removes a configured alert from a profile.voidRemoves all alerts currently in a profile.voidRemoves the firmware file from the profile.String[]Retrieves the names of the files which are in the profile.String[]retrieveFileNames(String[] extensions) Retrieves the names of the files which are stored on the device.Retrieves the properties of the objects which are stored on the device.voidsendContents(String fileNameOnPrinter, byte[] fileContents) Adds a file to the profile namedfileNameOnPrinterwith the file contents fromfileContents.voidsendFileContents(String filePath) This method is not valid for a profile.voidsendFileContents(String filePath, ProgressMonitor handler) This method is not valid for a profile.voidsetAllSettings(Map<String, Setting> settings) Change settings in the profile.voidsetSetting(String settingId, Setting setting) Change the setting in the profile.voidsetSetting(String settingId, String value) Change the value of the setting in the profile to the given value.voidsetSettings(Map<String, String> settingValuePairs) Set more than one setting.voidstoreFileOnPrinter(byte[] fileContents, String fileNameOnPrinter) Stores a file in the profile namedfileNameOnPrinterwith the file contents fromfileContentsusing any required file wrappers.voidstoreFileOnPrinter(String filePath) Stores the file in the profile using any required file wrappers.voidstoreFileOnPrinter(String filePath, String fileNameOnPrinter) Stores the file in the profile at the specified location and name using any required file wrappers.voidstoreFileOnPrinterProtected(String filePath, String authPassword) Stores the file on the printer in Protected Mode, available at the specified location and provided authentication password using the required file wrapper(s).voidstoreFileOnPrinterProtected(String filePath, String fileNameOnPrinter, String authPassword) Stores the file on the printer in Protected Mode, available at the specified location, with the specified name and provided authentication password using the required file wrapper(s).voidstoreImage(String deviceDriveAndFileName, ZebraImageI image, int width, int height) Stores the specifiedimageto the connected printer as a monochrome image.voidstoreImage(String deviceDriveAndFileName, String imageFullPath, int width, int height) Stores the specifiedimageto the connected printer as a monochrome image.
-
Constructor Details
-
Profile
Create aProfileobject backed by an existing .zprofile file.- Parameters:
pathToProfile- path to the profile file.- Throws:
FileNotFoundException- if the filepathToProfiledoes not exist.
-
-
Method Details
-
addSupplement
Adds data to supplement an existing printer profile. Any supplemental data added to a profile, upon loading the profile, will be sent to the printer after all other profile components have been applied.- Parameters:
supplementData- byte array containing the data to be used to supplement the printer profile.- Throws:
IOException- if there is an error writing to the .zprofile file.
-
getSupplement
Returns the supplement data within the profile.- Returns:
- the supplement data within the profile.
- Throws:
IOException- if there is an error reading the .zprofile file.FileNotFoundException- if the .zprofile file cannot be found.
-
addFirmware
Adds a firmware file to an existing printer profile. Upon loading the profile, if it contains a firmware file, the firmware will be sent to the printer before all other profile components.- Parameters:
pathToFirmwareFile- full path to the firmware file to be added to the profile.- Throws:
IOException- if there is an error readingpathToFirmwareFileor if there is an error writing to the .zprofile file.
-
addFirmware
Adds a firmware file to an existing printer profile. Upon loading the profile, if it contains a firmware file, the firmware will be sent to the printer before all other profile components.- Parameters:
firmwareFileName- the name of the firmware filefirmwareFileContents- the firmware file contents- Throws:
IOException- if there is an error readingpathToFirmwareFileor if there is an error writing to the .zprofile file.
-
removeFirmware
Removes the firmware file from the profile.- Throws:
IOException- if there is an error removing the firmware file from the .zprofile file.
-
getFirmwareFilename
Returns the file name of the firmware file within the profile.- Returns:
- the file name of the firmware file within the profile.
- Throws:
IOException- if there is an error reading the firmware file name in the .zprofile file.FileNotFoundException- if the firmware file cannot be found in the .zprofile file.
-
getAvailableSettings
Retrieve all of the setting identifiers for a profile. These are the IDs that may be used as keys for retrieving and updating settings for a profile.- Specified by:
getAvailableSettingsin interfaceSettingsProvider- Returns:
- Set of identifiers available for a profile.
- Throws:
SettingsException- if the settings could not be loaded.- See Also:
-
getSettingValue
Retrieves the profile's setting value for a setting id.- Specified by:
getSettingValuein interfaceSettingsProvider- Parameters:
settingId- setting id.- Returns:
- the setting's value.
- Throws:
SettingsException- if the setting could not be retrieved.
-
getSettingsValues
Retrieves the profile's setting values for a list of setting ids.- Specified by:
getSettingsValuesin interfaceSettingsProvider- Parameters:
listOfSettings- list of setting ids.- Returns:
- the settings' values.
- Throws:
SettingsException- if the setting could not be retrieved.
-
getAllSettingValues
Retrieves all of the profile's setting values.- Specified by:
getAllSettingValuesin interfaceSettingsProvider- Returns:
- Values of all the settings provided by the profile.
- Throws:
SettingsException- if the settings could not be loaded.- See Also:
-
setSetting
Change the value of the setting in the profile to the given value.- Specified by:
setSettingin interfaceSettingsProvider- Parameters:
settingId- setting id.value- The setting's value.- Throws:
SettingsException- if the setting is read only, does not exist, or if the setting could not be set.
-
setSettings
Set more than one setting.- Specified by:
setSettingsin interfaceSettingsProvider- Parameters:
settingValuePairs- Map a setting ID to the new value for the setting.- Throws:
SettingsException- if the settings cannot be saved in the profile.
-
getSettingRange
Description copied from interface:SettingsProviderRetrieves the allowable range for a setting.- Specified by:
getSettingRangein interfaceSettingsProvider- Parameters:
settingId- setting id.- Returns:
- the setting's range as a string
- Throws:
SettingsException- if the setting does not exist- See Also:
-
isSettingValid
Description copied from interface:SettingsProviderReturns true if value is valid for the given setting.- Specified by:
isSettingValidin interfaceSettingsProvider- Parameters:
settingId- setting id.value- the setting's value- Returns:
- true if value is valid for the given setting.
- Throws:
SettingsException- if the setting does not exist- See Also:
-
isSettingReadOnly
Description copied from interface:SettingsProviderReturns true if the setting is read only.- Specified by:
isSettingReadOnlyin interfaceSettingsProvider- Parameters:
settingId- the setting id- Returns:
- true if the setting is read only
- Throws:
SettingsException- if the setting does not exist- See Also:
-
isSettingWriteOnly
Description copied from interface:SettingsProviderReturns true if the setting is write only.- Specified by:
isSettingWriteOnlyin interfaceSettingsProvider- Parameters:
settingId- the setting id- Returns:
- true if the setting is write only
- Throws:
SettingsException- if the setting does not exist- See Also:
-
getSettingType
Description copied from interface:SettingsProviderReturns the data type of the setting.- Specified by:
getSettingTypein interfaceSettingsProvider- Parameters:
settingId- the setting id- Returns:
- the data type of the setting (e.g. string, bool, enum, etc.)
- Throws:
SettingsException- if the setting does not exist- See Also:
-
getArchivableSettingValues
Retrieve the values of all the settings that are archivable.- Returns:
- Values of all the settings with the archivable attribute that are in the profile.
- Throws:
SettingsException- if the settings could not be loaded.
-
getClonableSettingValues
Retrieve the values of all the settings that are clonable.- Returns:
- Values of all the settings with the clonable attribute that are in the profile.
- Throws:
SettingsException- if the settings could not be loaded.
-
getConfiguredAlerts
A list of objects detailing the alert configurations in a profile.- Specified by:
getConfiguredAlertsin interfaceAlertProvider- Returns:
- a list of alert objects currently in a profile.
- Throws:
ZebraIllegalArgumentException- if the alerts could not be extracted from the profile.
-
configureAlert
Description copied from interface:AlertProviderConfigures an alert to be triggered when the alert's condition occurs or becomes resolved.- Specified by:
configureAlertin interfaceAlertProvider- Parameters:
alert- the alert to trigger when it's condition occurs or becomes resolved.- Throws:
ConnectionException- See Also:
-
configureAlerts
Description copied from interface:AlertProviderConfigures a list of alerts to be triggered when their conditions occur or become resolved.- Specified by:
configureAlertsin interfaceAlertProvider- Parameters:
alerts- the list of alerts to trigger when their conditions occur or become resolved.- Throws:
ConnectionException- See Also:
-
removeAlert
Removes a configured alert from a profile. They may be reconfigured via the setAlert methods.- Specified by:
removeAlertin interfaceAlertProvider- Parameters:
alert- to be removed from the configuration- Throws:
ConnectionException
-
removeAllAlerts
Removes all alerts currently in a profile. They may be reconfigured via the setAlert(s) methods.- Specified by:
removeAllAlertsin interfaceAlertProvider- Throws:
ConnectionException- if an I/O error occurs.
-
downloadTtfFont
Adds a TrueType® font file to a profile and stores it at the specified path as a TTF.- Specified by:
downloadTtfFontin interfaceFontUtil- Parameters:
sourceFilePath- Path to a TrueType® font to be added to the profile.pathOnPrinter- Location to save the font file in the profile.- Throws:
ConnectionException- if an I/O error occurs.
-
downloadTteFont
Adds a TrueType® font file to a profile and stores it at the specified path as a TrueType® extension (TTE).- Specified by:
downloadTteFontin interfaceFontUtil- Parameters:
sourceFilePath- Path to a TrueType® font to be added to the profile.pathOnPrinter- Location to save the font file in the profile.- Throws:
ConnectionException- if an I/O error occurs.
-
downloadTtfFont
public void downloadTtfFont(InputStream sourceInputStream, String pathOnPrinter) throws ConnectionException Adds a TrueType® font file to a profile and stores it at the specified path as a TTF.- Specified by:
downloadTtfFontin interfaceFontUtil- Parameters:
sourceInputStream- Input Stream containing the font data.pathOnPrinter- Location to save the font file in the profile.- Throws:
ConnectionException- if an I/O error occurs.
-
downloadTteFont
public void downloadTteFont(InputStream sourceInputStream, String pathOnPrinter) throws ConnectionException Adds a TrueType® font to a profile and stores it at the specified path as a TrueType® extension (TTE).- Specified by:
downloadTteFontin interfaceFontUtil- Parameters:
sourceInputStream- Input Stream containing the font data.pathOnPrinter- Location to save the font file in the profile.- Throws:
ConnectionException- if an I/O error occurs.
-
sendFileContents
This method is not valid for a profile.- Specified by:
sendFileContentsin interfaceFileUtil- Parameters:
filePath-- Throws:
IllegalStateException- thrown if this method is called.
-
sendContents
Adds a file to the profile namedfileNameOnPrinterwith the file contents fromfileContents.- Parameters:
fileNameOnPrinter- the full name of the file on the printer (e.g "R:SAMPLE.ZPL").fileContents- The contents of the file to send.- Throws:
ConnectionException- if an I/O error occurs.
-
retrieveFileNames
Retrieves the names of the files which are in the profile.- Specified by:
retrieveFileNamesin interfaceFileUtil- Returns:
- list of file names.
-
retrieveFileNames
Retrieves the names of the files which are stored on the device. This method only returns files which have one of the extensions inextensions.- Specified by:
retrieveFileNamesin interfaceFileUtil- Parameters:
extensions- the extensions to filter on.- Returns:
- list of file names.
-
storeFileOnPrinter
public void storeFileOnPrinter(String filePath) throws ConnectionException, ZebraIllegalArgumentException Stores the file in the profile using any required file wrappers.
Note: If the contents offilePathcontains any commands which need to be processed by the printer, useFileUtil.sendFileContents(String)instead! These commands include download commands any immediate commands (~CC, ~CD, ~DB, ~DE, ~DG, ~DY, ~EG, ~HI, ~HU, ~HM, ~HQ, ~HS, ~JA, ~JB, ~JC, ~JD, ~JE, ~JF, ~JG, ~JI, ~JL, ~JN, ~JO, ~JP, ~JQ, ~JR, ~JS, ~JX, ~NC, ~NT, ~PL, ~PP, ~PR, ~PS, ~RO, ~SD, ~TA, ~WC, ~WQ, ^DF)- Specified by:
storeFileOnPrinterin interfaceFileUtilLinkOs- Parameters:
filePath- the full file path (e.g. "C:\\Users\\%USERNAME%\\Documents\\sample.zpl").- Throws:
ConnectionException- if there is an error connecting to the device.ZebraIllegalArgumentException- if filePath cannot be used to create a printer file name.
-
storeFileOnPrinter
public void storeFileOnPrinter(String filePath, String fileNameOnPrinter) throws ConnectionException Stores the file in the profile at the specified location and name using any required file wrappers.
Note: If the contents offilePathcontains any commands which need to be processed by the printer, useFileUtil.sendFileContents(String)instead! These commands include download commands any immediate commands (~CC, ~CD, ~DB, ~DE, ~DG, ~DY, ~EG, ~HI, ~HU, ~HM, ~HQ, ~HS, ~JA, ~JB, ~JC, ~JD, ~JE, ~JF, ~JG, ~JI, ~JL, ~JN, ~JO, ~JP, ~JQ, ~JR, ~JS, ~JX, ~NC, ~NT, ~PL, ~PP, ~PR, ~PS, ~RO, ~SD, ~TA, ~WC, ~WQ, ^DF)- Specified by:
storeFileOnPrinterin interfaceFileUtilLinkOs- Parameters:
filePath- the full file path (e.g. "C:\\Users\\%USERNAME%\\Documents\\sample.zpl").fileNameOnPrinter- the full name of the file on the printer (e.g "R:SAMPLE.ZPL").- Throws:
ConnectionException- if there is an error connecting to the device.
-
storeFileOnPrinter
public void storeFileOnPrinter(byte[] fileContents, String fileNameOnPrinter) throws ConnectionException Stores a file in the profile namedfileNameOnPrinterwith the file contents fromfileContentsusing any required file wrappers.
Note: If thefileContentscontains any commands which need to be processed by the printer, useFileUtil.sendFileContents(String)instead! These commands include download commands any immediate commands (~CC, ~CD, ~DB, ~DE, ~DG, ~DY, ~EG, ~HI, ~HU, ~HM, ~HQ, ~HS, ~JA, ~JB, ~JC, ~JD, ~JE, ~JF, ~JG, ~JI, ~JL, ~JN, ~JO, ~JP, ~JQ, ~JR, ~JS, ~JX, ~NC, ~NT, ~PL, ~PP, ~PR, ~PS, ~RO, ~SD, ~TA, ~WC, ~WQ, ^DF)- Specified by:
storeFileOnPrinterin interfaceFileUtilLinkOs- Parameters:
fileContents- The contents of the file to store.fileNameOnPrinter- the full name of the file on the printer (e.g "R:SAMPLE.ZPL").- Throws:
ConnectionException- if there is an error connecting to the device.
-
deleteFile
Deletes the file from the profile. ThefilePathmay also contain wildcards.- Specified by:
deleteFilein interfaceFileUtilLinkOs- Parameters:
filePath- the location of the file on the printer. Wildcards are also accepted (e.g. "E:FORMAT.ZPL", "E:*.*")- Throws:
ConnectionException- if there is an error accessing the profile.
-
getObjectFromPrinter
Retrieves a file from the profile and returns the contents of that file as a byte array. Will retrieve the following file extensions: ZPL, GRF, DAT, BAS, FMT, PNG, LBL, PCX, BMP, WML, CSV, HTM, BAE, TXT.
Files transferred between different printer models may not be compatible.- Specified by:
getObjectFromPrinterin interfaceFileUtilLinkOs- Parameters:
filePath- absolute file path on the printer ("E:SAMPLE.TXT").- Returns:
- The file contents
- Throws:
ZebraIllegalArgumentException- if the filePath is invalid, or if the file does not exist on the printer.
-
getObjectFromPrinter
public void getObjectFromPrinter(OutputStream destinationStream, String filePath) throws ZebraIllegalArgumentException Description copied from interface:FileUtilLinkOsRetrieves a file from the printer's file system and writes the contents of that file to destinationStream. Will retrieve the following file extensions: ZPL, GRF, DAT, BAS, FMT, PNG, LBL, PCX, BMP, WML, CSV, HTM, TXT.
Files transferred between different printer models may not be compatible.- Specified by:
getObjectFromPrinterin interfaceFileUtilLinkOs- Parameters:
destinationStream- output stream to receive the file contentsfilePath- absolute file path on the printer ("E:SAMPLE.TXT").- Throws:
ZebraIllegalArgumentException- if the filePath is invalid, or if the file does not exist on the printer.- See Also:
-
getObjectFromPrinterViaFtp
public byte[] getObjectFromPrinterViaFtp(String filePath, String ftpPassword) throws ZebraIllegalArgumentException This method is not valid for a profile.- Specified by:
getObjectFromPrinterViaFtpin interfaceFileUtilLinkOs- Parameters:
filePath-ftpPassword-- Returns:
- null
- Throws:
ZebraIllegalArgumentException- thrown if this method is called.
-
getObjectFromPrinterViaFtp
public void getObjectFromPrinterViaFtp(OutputStream destinationStream, String filePath, String ftpPassword) throws ConnectionException, ZebraIllegalArgumentException Description copied from interface:FileUtilLinkOsRetrieves a file from the printer's file system via FTP and writes the contents of that file to destinationStream. Will retrieve the following file extensions: ZPL, GRF, DAT, BAS, FMT, PNG, LBL, PCX, BMP, WML, CSV, HTM, TXT.
Files transferred between different printer models may not be compatible.
NOTE: This method retrieves files over a network protocol and hence will only work over a TCP connected printer with FTP enabled. IfftpPasswordis not provided, a default will be tried.- Specified by:
getObjectFromPrinterViaFtpin interfaceFileUtilLinkOs- Parameters:
destinationStream- output stream to receive the file contentsfilePath- absolute file path on the printer ("E:SAMPLE.TXT")ftpPassword- password used to login to FTP, if null, a default password ("1234") will be used.- Throws:
ConnectionException- if there is an error communicating with the printer, or the ftpPassword is invalidZebraIllegalArgumentException- if the filePath is invalid, or if the file does not exist on the printer.- See Also:
-
getPrinterDownloadableObjectFromPrinter
public byte[] getPrinterDownloadableObjectFromPrinter(String filePath) throws ZebraIllegalArgumentException Retrieves a file from the profile and returns the contents of that file as a byte array including all necessary file wrappers for redownloading to a Zebra printer. Will retrieve the following file extensions: ZPL, GRF, DAT, BAS, FMT, PNG, LBL, PCX, BMP, WML, CSV, HTM, BAE, TXT
Files transferred between different printer models may not be compatible.- Specified by:
getPrinterDownloadableObjectFromPrinterin interfaceFileUtilLinkOs- Parameters:
filePath- absolute file path on the printer ("E:SAMPLE.TXT")- Returns:
- A Zebra printer downloadable file content.
- Throws:
ZebraIllegalArgumentException- if the filePath is invalid, or if the file does not exist on the printer.
-
getStorageInfo
This method is not valid for a profile.- Specified by:
getStorageInfoin interfaceFileUtilLinkOs- Returns:
- null
- Throws:
ConnectionException- thrown if this method is called.- See Also:
-
sendFileContents
This method is not valid for a profile.- Specified by:
sendFileContentsin interfaceFileUtil- Parameters:
filePath-handler-- Throws:
IllegalStateException- thrown if this method is called.
-
retrieveObjectsProperties
public List<PrinterObjectProperties> retrieveObjectsProperties() throws ZebraIllegalArgumentExceptionDescription copied from interface:FileUtilRetrieves the properties of the objects which are stored on the device.- Specified by:
retrieveObjectsPropertiesin interfaceFileUtil- Returns:
- the list of objects with their properties.
- Throws:
ZebraIllegalArgumentException- if there is an error parsing the directory data returned by the device.- See Also:
-
getAllSettings
Description copied from interface:SettingsProviderRetrieve all settings and their attributes.- Specified by:
getAllSettingsin interfaceSettingsProvider- Returns:
- Map of setting IDs and setting attributes contained in the profile
- Throws:
SettingsException- if the settings could not be retrieved- See Also:
-
printImage
Description copied from interface:GraphicsUtilPrints an image from the connecting device file system to the connected device as a monochrome image.
Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw anOutOfMemoryErrorexception.- Specified by:
printImagein interfaceGraphicsUtil- Parameters:
imageFilePath- image file to be printed.x- horizontal starting position in dots.y- vertical starting position in dots.- Throws:
ConnectionException- if an I/O error occurs.IOException- when the file could not be found, opened, or is an unsupported graphic- See Also:
-
printImage
public void printImage(String imageFilePath, int x, int y, int width, int height, boolean insideFormat) throws ConnectionException, IOException Description copied from interface:GraphicsUtilPrints an image from the connecting device file system to the connected device as a monochrome image.
Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw anOutOfMemoryErrorexception.- Specified by:
printImagein interfaceGraphicsUtil- Parameters:
imageFilePath- image file to be printed.x- horizontal starting position in dots.y- vertical starting position in dots.width- desired width of the printed image. Passing a value less than 1 will preserve original width.height- desired height of the printed image. Passing a value less than 1 will preserve original height.insideFormat- boolean value indicating whether this image should be printed by itself (false), or is part of a format being written to the connection (true).- Throws:
ConnectionException- if an I/O error occurs.IOException- when the file could not be found, opened, or is an unsupported graphic- See Also:
-
printImage
public void printImage(ZebraImageI image, int x, int y, int width, int height, boolean insideFormat) throws ConnectionException Description copied from interface:GraphicsUtilPrints an image to the connected device as a monochrome image.
Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw anOutOfMemoryErrorexception.- Specified by:
printImagein interfaceGraphicsUtil- Parameters:
image- the image to be printed.x- horizontal starting position in dots.y- vertical starting position in dots.width- desired width of the printed image. Passing a value less than 1 will preserve original width.height- desired height of the printed image. Passing a value less than 1 will preserve original height.insideFormat- boolean value indicating whether this image should be printed by itself (false), or is part of a format being written to the connection (true).- Throws:
ConnectionException- if an I/O error occurs.- See Also:
-
storeImage
public void storeImage(String deviceDriveAndFileName, ZebraImageI image, int width, int height) throws ConnectionException, ZebraIllegalArgumentException Description copied from interface:GraphicsUtilStores the specifiedimageto the connected printer as a monochrome image. The image will be stored on the printer atprinterDriveAndFileNamewith the extension GRF. If a drive letter is not supplied, E will be used as the default (e.g. FILE becomes E:FILE.GRF). If an extension is supplied, it is ignored if it is not either BMP or PNG. If the extension is ignored, GRF will be used.If the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryErrorexception.- Specified by:
storeImagein interfaceGraphicsUtil- Parameters:
deviceDriveAndFileName- path on the printer where the image will be stored.image- the image to be stored on the printer.width- desired width of the printed image, in dots. Passing -1 will preserve original width.height- desired height of the printed image, in dots. Passing -1 will preserve original height.- Throws:
ConnectionException- if there is an issue communicating with the printer (e.g. the connection is not open).ZebraIllegalArgumentException- ifprinterDriveAndFileNamehas an incorrect format.- See Also:
-
storeImage
public void storeImage(String deviceDriveAndFileName, String imageFullPath, int width, int height) throws ConnectionException, ZebraIllegalArgumentException, IOException Description copied from interface:GraphicsUtilStores the specifiedimageto the connected printer as a monochrome image. The image will be stored on the printer atprinterDriveAndFileNamewith the extension GRF. If a drive letter is not supplied, E will be used as the default (e.g. FILE becomes E:FILE.GRF). If an extension is supplied, it is ignored if it is not either BMP or PNG. If the extension is ignored, GRF will be used.If the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryErrorexception.- Specified by:
storeImagein interfaceGraphicsUtil- Parameters:
deviceDriveAndFileName- path on the printer where the image will be stored.imageFullPath- image file to be stored on the printer.width- desired width of the printed image, in dots. Passing -1 will preserve original width.height- desired height of the printed image, in dots. Passing -1 will preserve original height.- Throws:
ConnectionException- if there is an issue communicating with the printer (e.g. the connection is not open).ZebraIllegalArgumentException- ifprinterDriveAndFileNamehas an incorrect format.IOException- when the file could not be found, opened, or is an unsupported graphic- See Also:
-
getSetting
Retrieves the profile'sSettingfor a setting id.- Parameters:
settingId- setting id.- Returns:
- the
Setting - Throws:
SettingsException- if the setting could not be retrieved.
-
setSetting
Change the setting in the profile.- Parameters:
settingId- setting id.setting- The setting.- Throws:
SettingsException- if the setting is malformed, or if the setting could not be set.
-
setAllSettings
Change settings in the profile.- Parameters:
settings- The settings to change- Throws:
SettingsException- if a setting is malformed, or one or more settings could not be set.
-
processSettingsViaMap
public Map<String,String> processSettingsViaMap(Map<String, String> settingValuePairs) throws SettingsException, ConnectionExceptionChange or retrieve settings in the profile.- Specified by:
processSettingsViaMapin interfaceSettingsProvider- Parameters:
settingValuePairs- The settings to change- Returns:
- Mapinvalid input: '<'String, String> results of the setting commands
- Throws:
SettingsException- if a setting is malformed, or one or more settings could not be set.ConnectionException- if there is an error communicating with the printer.
-
storeFileOnPrinterProtected
public void storeFileOnPrinterProtected(String filePath, String authPassword) throws ConnectionException, IOException, ZebraIllegalArgumentException Description copied from interface:FileUtilLinkOsStores the file on the printer in Protected Mode, available at the specified location and provided authentication password using the required file wrapper(s). This method provides authentication to store NRD, NRE and PAC file types from the local file system to the printer's file system. Filenames will be truncated to 8.3 format.
Note: If thefileContentscontains any commands which need to be processed by the printer, useFileUtil.sendFileContents(String)instead. These commands include download commands and any immediate commands (~CC, ~CD, ~DB, ~DE, ~DG, ~DY, ~EG, ~HI, ~HU, ~HM, ~HQ, ~HS, ~JA, ~JB, ~JC, ~JD, ~JE, ~JF, ~JG, ~JI, ~JL, ~JN, ~JO, ~JP, ~JQ, ~JR, ~JS, ~JX, ~NC, ~NT, ~PL, ~PP, ~PR, ~PS, ~RO, ~SD, ~TA, ~WC, ~WQ, ^DF)- Specified by:
storeFileOnPrinterProtectedin interfaceFileUtilLinkOs- Parameters:
filePath- the full file path (e.g. "C:\\Users\\%USERNAME%\\Documents\\sample.NRD").authPassword- the password required to access the stored file on the printer- Throws:
ConnectionException- if there is an error connecting to the device.IOException- if there is an issue reading the fileZebraIllegalArgumentException- if filePath cannot be used to create a printer file name or if authPassword is null or empty.- See Also:
-
storeFileOnPrinterProtected
public void storeFileOnPrinterProtected(String filePath, String fileNameOnPrinter, String authPassword) throws ConnectionException, IOException, ZebraIllegalArgumentException Description copied from interface:FileUtilLinkOsStores the file on the printer in Protected Mode, available at the specified location, with the specified name and provided authentication password using the required file wrapper(s).This method provides authentication to store NRD, NRE and PAC file types from the local file system to the printer's file system. The filename can be up to 16 characters long.
Note: If the
fileContentscontains any commands which need to be processed by the printer, useFileUtil.sendFileContents(String)instead. These commands include download commands and any immediate commands (~CC, ~CD, ~DB, ~DE, ~DG, ~DY, ~EG, ~HI, ~HU, ~HM, ~HQ, ~HS, ~JA, ~JB, ~JC, ~JD, ~JE, ~JF, ~JG, ~JI, ~JL, ~JN, ~JO, ~JP, ~JQ, ~JR, ~JS, ~JX, ~NC, ~NT, ~PL, ~PP, ~PR, ~PS, ~RO, ~SD, ~TA, ~WC, ~WQ, ^DF)- Specified by:
storeFileOnPrinterProtectedin interfaceFileUtilLinkOs- Parameters:
filePath- the path to the file on the local system to be storedfileNameOnPrinter- the desired name for the file when stored on the printerauthPassword- the password required to store file on the protected printer- Throws:
ConnectionException- if a connection error occurs while communicating with the printerIOException- if an I/O error occurs during file transferZebraIllegalArgumentException- if any of the provided arguments are invalid or null- See Also:
-
deleteFileOnPrinterProtected
public void deleteFileOnPrinterProtected(String filePath, String authPassword) throws ConnectionException, ZebraIllegalArgumentException Description copied from interface:FileUtilLinkOsDeletes the file from the printer on protected mode. ThefilePathmay also contain wildcards. When a NRD, NRE and PAC type files is in protected mode printer, it deletes file using the provided authentication password.- Specified by:
deleteFileOnPrinterProtectedin interfaceFileUtilLinkOs- Parameters:
filePath- the location of the file on the printer. Wildcards are also accepted (e.g. "E:FORMAT.NRD", "E:*.*")authPassword- the password required to access the stored file on the protected printer- Throws:
ConnectionException- if a connection error occurs while communicating with the printerZebraIllegalArgumentException- if any of the provided arguments are invalid or null- See Also:
-