public interface GraphicsUtil
package test.zebra.sdk.printer.examples;
import java.io.IOException;
import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
public class GraphicsUtilExample {
public static void main(String[] args) throws Exception {
Connection connection = new TcpConnection("192.168.1.32", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
int x = 0;
int y = 0;
printer.printImage("/sdcard/sample.jpg", x, y);
} 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 |
printImage(String imageFilePath,
int x,
int y)
Prints an image from the connecting device file system to the connected device as a monochrome image.
|
void |
printImage(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.
|
void |
printImage(ZebraImageI image,
int x,
int y,
int width,
int height,
boolean insideFormat)
Prints an image to the connected device as a monochrome image.
|
void |
storeImage(String deviceDriveAndFileName,
String imageFullPath,
int width,
int height)
Stores the specified
image to the connected printer as a monochrome image. |
void |
storeImage(String deviceDriveAndFileName,
ZebraImageI image,
int width,
int height)
Stores the specified
image to the connected printer as a monochrome image. |
void printImage(String imageFilePath, int x, int y) throws ConnectionException, IOException
OutOfMemoryError
exception.imageFilePath
- image file to be printed.x
- horizontal starting position in dots.y
- vertical starting position in dots.ConnectionException
- if an I/O error occurs.IOException
- when the file could not be found, opened, or is an unsupported graphicvoid printImage(String imageFilePath, int x, int y, int width, int height, boolean insideFormat) throws ConnectionException, IOException
OutOfMemoryError
exception.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).ConnectionException
- if an I/O error occurs.IOException
- when the file could not be found, opened, or is an unsupported graphicvoid printImage(ZebraImageI image, int x, int y, int width, int height, boolean insideFormat) throws ConnectionException
OutOfMemoryError
exception.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).ConnectionException
- if an I/O error occurs.void storeImage(String deviceDriveAndFileName, ZebraImageI image, int width, int height) throws ConnectionException, ZebraIllegalArgumentException
image
to the connected printer as a monochrome image. The image will be stored
on the printer at printerDriveAndFileName
with 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
(E:FILE.BMP becomes E:FILE.GRF). OutOfMemoryError
exception. 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.ConnectionException
- if there is an issue communicating with the printer (e.g. the connection is not
open).ZebraIllegalArgumentException
- if printerDriveAndFileName
has an incorrect format.void storeImage(String deviceDriveAndFileName, String imageFullPath, int width, int height) throws ConnectionException, ZebraIllegalArgumentException, IOException
image
to the connected printer as a monochrome image. The image will be stored
on the printer at printerDriveAndFileName
with 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
(E:FILE.BMP becomes E:FILE.GRF). OutOfMemoryError
exception. 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.ConnectionException
- if there is an issue communicating with the printer (e.g. the connection is not
open).ZebraIllegalArgumentException
- if printerDriveAndFileName
has an incorrect format.IOException
- when the file could not be found, opened, or is an unsupported graphic
© 2015 ZIH Corp. All Rights Reserved.