Interface GraphicsUtil

All Known Subinterfaces:
ZebraPrinter, ZebraPrinterLinkOs
All Known Implementing Classes:
Profile

public interface GraphicsUtil
This is an utility class for printing images on a device.

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

    Modifier and Type
    Method
    Description
    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
    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
    storeImage(String deviceDriveAndFileName, ZebraImageI image, int width, int height)
    Stores the specified image to the connected printer 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.
  • Method Details

    • printImage

      void printImage(String imageFilePath, int x, int y) throws ConnectionException, IOException
      Prints an image from the connecting device file system to the connected device as a monochrome image.
      Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryError exception.
      Parameters:
      imageFilePath - image file to be printed.
      x - horizontal starting position in dots.
      y - vertical starting position in dots.
      Throws:
      ConnectionException - if an I/O error occurs.
      IOException - when the file could not be found, opened, or is an unsupported graphic
    • printImage

      void printImage(String imageFilePath, int x, int y, int width, int height, boolean insideFormat) throws ConnectionException, IOException
      Prints an image from the connecting device file system to the connected device as a monochrome image.
      Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryError exception.
      Parameters:
      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).
      Throws:
      ConnectionException - if an I/O error occurs.
      IOException - when the file could not be found, opened, or is an unsupported graphic
    • printImage

      void printImage(ZebraImageI image, int x, int y, int width, int height, boolean insideFormat) throws ConnectionException
      Prints an image to the connected device as a monochrome image.
      Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryError exception.
      Parameters:
      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).
      Throws:
      ConnectionException - if an I/O error occurs.
    • storeImage

      void storeImage(String deviceDriveAndFileName, ZebraImageI image, int width, int height) throws ConnectionException, ZebraIllegalArgumentException
      Stores the specified 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 if it is not either BMP or PNG. If the extension is ignored, GRF will be used. If the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryError exception.
      Parameters:
      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.
      Throws:
      ConnectionException - if there is an issue communicating with the printer (e.g. the connection is not open).
      ZebraIllegalArgumentException - if printerDriveAndFileName has an incorrect format.
    • storeImage

      void storeImage(String deviceDriveAndFileName, String imageFullPath, int width, int height) throws ConnectionException, ZebraIllegalArgumentException, IOException
      Stores the specified 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 if it is not either BMP or PNG. If the extension is ignored, GRF will be used. If the image resolution is large (e.g. 1024x768) this method may take a long time to execute or throw an OutOfMemoryError exception.
      Parameters:
      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.
      Throws:
      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