Interface FormatUtilLinkOs

All Known Subinterfaces:
ZebraPrinterLinkOs

public interface FormatUtilLinkOs
Defines functions used for interacting with Link-OS™ printer formats.

package test.zebra.sdk.printer.examples;
 
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
 import com.zebra.sdk.comm.Connection;
 import com.zebra.sdk.comm.ConnectionException;
 import com.zebra.sdk.comm.TcpConnection;
 import com.zebra.sdk.graphics.ZebraImageFactory;
 import com.zebra.sdk.graphics.ZebraImageI;
 import com.zebra.sdk.printer.ZebraPrinterFactory;
 import com.zebra.sdk.printer.ZebraPrinterLinkOs;
 
 public class FormatUtilLinkOsExample {
 
     // Print a stored format with the given variables. This ZPL will store a format on the Link-OS™ printer, for
     // use with
     // example2. <code>
     // ^XA
     // ^DFE:FORMAT2.ZPL
     // ^FS
     // ^FT26,243^A0N,56,55^FH\^FN12"First Name"^FS
     // ^FT26,296^A0N,56,55^FH\^FN11"Last Name"^FS
     // ^FT258,73^A0N,39,38^FH\^FDVisitor^FS
     // ^FO100,100^XG^FN13,1,1^FS
     // ^FO5,17^GB601,379,8^FS
     // ^XZ
     // </code>
 
     public static void main(String[] args) throws Exception {
         String pathToImageFileOnHost = "c:\\example.png";
         Connection connection = new TcpConnection("1.2.3.4", TcpConnection.DEFAULT_ZPL_TCP_PORT);
         try {
             connection.open();
             Map<Integer, String> vars = new HashMap<Integer, String>();
             Map<Integer, ZebraImageI> imgVars = new HashMap<Integer, ZebraImageI>();
             vars.put(12, "John");
             vars.put(11, "Smith");
             ZebraImageI image = ZebraImageFactory.getImage(pathToImageFileOnHost);
             imgVars.put(13, image);
             ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.getLinkOsPrinter(connection);
             if (linkOsPrinter != null) {
                 linkOsPrinter.printStoredFormatWithVarGraphics("E:FORMAT2.ZPL", imgVars, vars);
             }
         } catch (ConnectionException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
         } finally {
             connection.close();
         }
     }
 }
 
  • Method Details

    • printStoredFormatWithVarGraphics

      void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,String> vars) throws ConnectionException
      Prints a stored format on the printer, filling in the fields specified by the Map. The values of any format variables will be encoded using the default encoding type.
      See java.lang.String for more information about encoding types.
      Parameters:
      storedFormatPath - the location of the file on the printer (e.g. "E:FORMAT.ZPL").
      vars - a map which contains the key/value pairs for the stored format. For ZPL formats, the key number should correspond directly to the number of the field in the format. For CPCL formats, the values will be passed in ascending numerical order.
      Throws:
      ConnectionException - if an I/O error occurs.
    • printStoredFormatWithVarGraphics

      void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,String> vars, String encoding) throws ConnectionException
      Prints a stored format on the printer, filling in the fields specified by the Map. The values of any format variables will be encoded using the provided encoding type. eg. UTF-8.
      See java.lang.String for more information about encoding types.
      Parameters:
      storedFormatPath - the location of the file on the printer (e.g. "E:FORMAT.ZPL").
      vars - a map which contains the key/value pairs for the stored format. For ZPL formats, the key number should correspond directly to the number of the field in the format. For CPCL formats, the values will be passed in ascending numerical order.
      encoding - a character-encoding name (e.g. UTF-8)
      Throws:
      ConnectionException - if an I/O error occurs.
    • printStoredFormatWithVarGraphics

      void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,ZebraImageI> imgVars, Map<Integer,String> vars) throws ConnectionException
      Prints a stored format on the printer, filling in the fields specified by the maps. The images stored in imgVars will first be dithered and then sent down the the printer as SDK01.GRF-SDK99.GRF. These GRF files will then be used when printing the format and overwritten each time the method is called with new images.The values of any format variables will be encoded using the default encoding type.
      See java.lang.String for more information about encoding types.
      Parameters:
      storedFormatPath - the location of the file on the printer (e.g. "E:FORMAT.ZPL").
      imgVars - a map which contains the key/value pairs for the images to be used in the stored format. For ZPL formats, the key number should correspond directly to the number of the field in the format. For CPCL formats, the values will be passed in ascending numerical order.
      vars - a map which contains the key/value pairs for the text variables to be used in the stored format. For ZPL formats, the key number should correspond directly to the number of the field in the format. For CPCL formats, the values will be passed in ascending numerical order.
      Throws:
      ConnectionException - if an I/O error occurs
    • printStoredFormatWithVarGraphics

      void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,ZebraImageI> imgVars, Map<Integer,String> vars, String encoding) throws ConnectionException
      Prints a stored format on the printer, filling in the fields specified by the maps. The images stored in imgVars will first be dithered and then sent down the the printer as SDK01.GRF-SDK99.GRF. These GRF files will then be used when printing the format and overwritten each time the method is called with new images.The values of any format variables will be encoded using the provided encoding type. eg. UTF-8.
      See java.lang.String for more information about encoding types.
      Parameters:
      storedFormatPath - the location of the file on the printer (e.g. "E:FORMAT.ZPL").
      imgVars - a map which contains the key/value pairs for the images to be used in the stored format. For ZPL formats, the key number should correspond directly to the number of the field in the format. For CPCL formats, the values will be passed in ascending numerical order.
      vars - a map which contains the key/value pairs for the text variables to be used in the stored format. For ZPL formats, the key number should correspond directly to the number of the field in the format. For CPCL formats, the values will be passed in ascending numerical order.
      encoding - a character-encoding name (e.g. UTF-8)
      Throws:
      ConnectionException - if an I/O error occurs.