Interface ProfileUtil

All Known Subinterfaces:
ZebraPrinterLinkOs

public interface ProfileUtil
Defines functions used for creating and applying profiles to a Zebra printer.

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();
         }
     }
 }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createBackup(String pathToOutputFile)
    Save a backup of your printer's settings, alerts, and files for later restoration.
    void
    createProfile(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.
  • Method Details

    • createProfile

      void createProfile(String pathToOutputFile) throws IOException, ZebraIllegalArgumentException, ConnectionException
      Create a profile of your printer's settings, alerts, and files for cloning to other printers. A profile contains setting values which can be used to clone another printer to match the original configuration. Some settings (such as I.P. address) which could conflict with the original printer will not be contained in the profile.
      Parameters:
      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.
      Throws:
      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.
      See Also:
    • createProfile

      void createProfile(OutputStream profileDestinationStream) throws IOException, ZebraIllegalArgumentException, ConnectionException
      Create a profile of your printer's settings, alerts, and files for cloning to other printers. A profile contains setting values which can be used to clone another printer to match the original configuration. Some settings (such as I.P. address) which could conflict with the original printer will not be contained in the profile.
      Parameters:
      profileDestinationStream - The destination stream where you want to write the profile.
      Throws:
      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.
    • createBackup

      void createBackup(String pathToOutputFile) throws IOException, ZebraIllegalArgumentException, ConnectionException
      Save a backup of your printer's settings, alerts, and files for later restoration. A backup contains a snapshot of all pertinent settings to fully restore your printer.
      Parameters:
      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.
      Throws:
      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.
      See Also:
    • loadProfile

      void loadProfile(String pathToProfile) throws IOException, ConnectionException
      Takes settings, alerts, and files from a profile, and applies them to a printer.
      Parameters:
      pathToProfile - Path to the profile to load. (e.g. /home/user/profile.zprofile)
      Throws:
      IOException - if the profile does not exist or could not be read.
      ConnectionException - if there is an error communicating with the printer.
    • loadProfile

      void loadProfile(String pathToProfile, FileDeletionOption filesToDelete, boolean isVerbose) throws IOException, ConnectionException
      Takes settings, alerts, and files from a profile, and applies them to a printer. Before doing so, it deletes the files described by filesToDelete from the printer.
      Parameters:
      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 profile
      Throws:
      IOException - if the profile does not exist or could not be read.
      ConnectionException - if there is an error communicating with the printer.
    • loadBackup

      void loadBackup(String pathToBackup) throws IOException, ConnectionException
      Takes settings, alerts, and files from a backup, and applies them to a printer. This method will also delete all files on your printer before applying the backup.
      Parameters:
      pathToBackup - Path to the profile to load. (e.g. /home/user/profile.zprofile)
      Throws:
      IOException - if the profile does not exist or could not be read.
      ConnectionException - if there is an error communicating with the printer.
    • loadBackup

      void loadBackup(String pathToBackup, boolean isVerbose) throws IOException, ConnectionException
      Takes settings, alerts, and files from a backup, and applies them to a printer. This method will also delete all files on your printer before applying the backup.
      Parameters:
      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 profile
      Throws:
      IOException - if the profile does not exist or could not be read.
      ConnectionException - if there is an error communicating with the printer.