public interface FormatUtilLinkOs
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.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
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);
ZebraPrinter genericPrinter = ZebraPrinterFactory.getInstance(connection);
ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.createLinkOsPrinter(genericPrinter);
if (linkOsPrinter != null) {
linkOsPrinter.printStoredFormatWithVarGraphics("E:FORMAT2.ZPL", imgVars, vars);
}
} catch (ConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
}
Modifier and Type | Method and Description |
---|---|
void |
printStoredFormatWithVarGraphics(String storedFormatPath,
Map<Integer,String> vars)
Prints a stored format on the printer, filling in the fields specified by the
Map . |
void |
printStoredFormatWithVarGraphics(String storedFormatPath,
Map<Integer,String> vars,
String encoding)
Prints a stored format on the printer, filling in the fields specified by the
Map . |
void |
printStoredFormatWithVarGraphics(String storedFormatPath,
Map<Integer,ZebraImageI> imgVars,
Map<Integer,String> vars)
Prints a stored format on the printer, filling in the fields specified by the maps.
|
void |
printStoredFormatWithVarGraphics(String storedFormatPath,
Map<Integer,ZebraImageI> imgVars,
Map<Integer,String> vars,
String encoding)
Prints a stored format on the printer, filling in the fields specified by the maps.
|
void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,String> vars) throws ConnectionException
Map
. The values of any
format variables will be encoded using the default encoding type. 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.ConnectionException
- if an I/O error occurs.void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,String> vars, String encoding) throws ConnectionException
Map
. The values of any
format variables will be encoded using the provided encoding
type. eg. UTF-8. 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)ConnectionException
- if an I/O error occurs.void printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,ZebraImageI> imgVars, Map<Integer,String> vars) throws ConnectionException
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.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.ConnectionException
- if an I/O error occursvoid printStoredFormatWithVarGraphics(String storedFormatPath, Map<Integer,ZebraImageI> imgVars, Map<Integer,String> vars, String encoding) throws ConnectionException
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.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)ConnectionException
- if an I/O error occurs.
© 2016 ZIH Corp. All Rights Reserved.