public interface ProfileUtil
package test.zebra.sdk.printer.examples;
import java.io.IOException;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.device.ZebraIllegalArgumentException;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLinkOs;
public class ProfileUtilExample {
enum ProfileOperations {
create_profile, restore_backup, clone_a_printer
};
public static void main(String[] args) throws Exception {
String pathToProfile = "C:\\MyNewProfile.zprofile";
ProfileOperations whatToDo = ProfileOperations.create_profile; // Change this to load the profile.
TcpConnection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.open();
ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.getLinkOsPrinter(connection);
if (linkOsPrinter != null) {
System.out.println("Start profile operation");
switch (whatToDo) {
case create_profile:
linkOsPrinter.createProfile(pathToProfile);
break;
case restore_backup:
linkOsPrinter.loadBackup(pathToProfile);
break;
case clone_a_printer:
linkOsPrinter.loadProfile(pathToProfile);
break;
}
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();
} finally {
connection.close();
}
}
}
Modifier and Type | Method and Description |
---|---|
void |
createBackup(String pathToOutputFile)
Save a backup of your printer's settings, alerts, and files for later restoration.
|
void |
createProfile(java.io.OutputStream profileDestinationStream)
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
|
void |
createProfile(String pathToOutputFile)
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
|
void |
loadBackup(String pathToBackup)
Takes settings, alerts, and files from a backup, and applies them to a printer.
|
void |
loadBackup(String pathToBackup,
boolean isVerbose)
Takes settings, alerts, and files from a backup, and applies them to a printer.
|
void |
loadProfile(String pathToProfile)
Takes settings, alerts, and files from a profile, and applies them to a printer.
|
void |
loadProfile(String pathToProfile,
FileDeletionOption filesToDelete,
boolean isVerbose)
Takes settings, alerts, and files from a profile, and applies them to a printer.
|
void createProfile(String pathToOutputFile) throws java.io.IOException, ZebraIllegalArgumentException, ConnectionException
pathToOutputFile
- Path on your local machine where you want to save the profile. (e.g.
/home/user/profile.zprofile). The extension must be .zprofile; if it is not, the method will change it to
.zprofile for you.java.io.IOException
- if the output file could not be created.ZebraIllegalArgumentException
- Could not interpret the response from the printer.ConnectionException
- if there is an error communicating with the printer.ZebraPrinter.loadProfile(String) for loading a profile to another
printer
void createProfile(java.io.OutputStream profileDestinationStream) throws java.io.IOException, ZebraIllegalArgumentException, ConnectionException
profileDestinationStream
- The destination stream where you want to write the profile.java.io.IOException
- if the output file could not be created.ZebraIllegalArgumentException
- Could not interpret the response from the printer.ConnectionException
- if there is an error communicating with the printer.void createBackup(String pathToOutputFile) throws java.io.IOException, ZebraIllegalArgumentException, ConnectionException
pathToOutputFile
- Path on your local machine where you want to save the backup. (e.g.
/home/user/profile.zprofile). The extension must be .zprofile; if it is not, the method will change it to
.zprofile for you.java.io.IOException
- if the output file could not be created.ZebraIllegalArgumentException
- Could not interpret the response from the printer.ConnectionException
- if there is an error communicating with the printer.ZebraPrinter.loadProfile(String) for loading the backup file to
another printer
void loadProfile(String pathToProfile) throws java.io.IOException, ConnectionException
pathToProfile
- Path to the profile to load. (e.g. /home/user/profile.zprofile)java.io.IOException
- if the profile does not exist or could not be read.ConnectionException
- if there is an error communicating with the printer.void loadProfile(String pathToProfile, FileDeletionOption filesToDelete, boolean isVerbose) throws java.io.IOException, ConnectionException
filesToDelete
from the printer.pathToProfile
- 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 when loading firmware from the profilejava.io.IOException
- if the profile does not exist or could not be read.ConnectionException
- if there is an error communicating with the printer.void loadBackup(String pathToBackup) throws java.io.IOException, ConnectionException
pathToBackup
- Path to the profile to load. (e.g. /home/user/profile.zprofile)java.io.IOException
- if the profile does not exist or could not be read.ConnectionException
- if there is an error communicating with the printer.void loadBackup(String pathToBackup, boolean isVerbose) throws java.io.IOException, ConnectionException
pathToBackup
- Path to the profile to load. (e.g. /home/user/profile.zprofile)isVerbose
- increases the amount of detail presented to the user when loading firmware from the profilejava.io.IOException
- if the profile does not exist or could not be read.ConnectionException
- if there is an error communicating with the printer.
© 2017 ZIH Corp. All Rights Reserved.