ZSDK_API  1.5.1049
 All Classes Functions Enumerations Enumerator Properties Pages
<GraphicsUtil> Protocol Referenceabstract

This is an utility class for printing images on a printer. More...

#import <GraphicsUtil.h>

Instance Methods

(BOOL) - printImageFromFile:atX:atY:error:
 Prints an image from the Apple® mobile digital device's file system to the connected printer as a monochrome image.
 
(BOOL) - printImageFromFile:atX:atY:withWidth:withHeight:andIsInsideFormat:error:
 Prints an image from the Apple® mobile digital device's file system to the connected printer as a monochrome image.
 
(BOOL) - printImage:atX:atY:withWidth:withHeight:andIsInsideFormat:error:
 Prints the given image to the connected printer as a monochrome image.
 
(BOOL) - storeImage:withImage:withWidth:andWithHeight:error:
 Stores the specified image to the connected printer as a monochrome image.
 
(BOOL) - storeImage:withPathOnDevice:withWidth:andWithHeight:error:
 Stores an image from the Apple® mobile digital device's file system to the connected printer as a monochrome image.
 

Detailed Description

This is an utility class for printing images on a printer.

Print an image from the device to a printer.

#import "TcpPrinterConnection.h"
#import <UIKit/UIKit.h>
#import "ZebraPrinter.h"
#import "ZebraPrinterFactory.h"
TcpPrinterConnection *zebraPrinterConnection = [[TcpPrinterConnection alloc] initWithAddress:@"192.168.1.100" andWithPort:6101];
BOOL success = [zebraPrinterConnection open];
NSError *error = nil;
id<ZebraPrinter,NSObject> printer = [ZebraPrinterFactory getInstance:zebraPrinterConnection error:&error];
NSInteger x = 100;
NSInteger y = 200;
success = success && [[printer getGraphicsUtil] printImageFromFile:@"/Documents/sample.jpg" atX:x atY:y error:&error];
[zebraPrinterConnection close];
if (error != nil || printer == nil || success == NO) {
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}
[zebraPrinterConnection release];
See Also
- getGraphicsUtil (ZebraPrinter-p)

Method Documentation

- (BOOL) printImage: (CGImageRef)  image
atX: (NSInteger)  x
atY: (NSInteger)  y
withWidth: (NSInteger)  width
withHeight: (NSInteger)  height
andIsInsideFormat: (BOOL)  isInsideFormat
error: (NSError **)  error 

Prints the given image to the connected printer as a monochrome image.


Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute.

Parameters
imageThe image to print.
xHorizontal starting position in dots.
yVertical starting position in dots.
widthDesired width of the printed image. Passing -1 will preserve original width.
heightDesired height of the printed image. Passing -1 will preserve original height.
isInsideFormatBoolean value indicating whether this image should be printed by itself (NO), or is part of a format being written to the connection (YES).
errorWill be set to the error that occured.
Returns
NO if there was an error printing the image.
- (BOOL) printImageFromFile: (NSString *)  path
atX: (NSInteger)  x
atY: (NSInteger)  y
error: (NSError **)  error 

Prints an image from the Apple® mobile digital device's file system to the connected printer as a monochrome image.


Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute.

Parameters
pathFull path to image file. (The image must be either a PNG or JPG).
xHorizontal starting position in dots.
yVertical starting position in dots.
errorWill be set to the error that occured.
Returns
NO if there was an error printing the image.
- (BOOL) printImageFromFile: (NSString *)  path
atX: (NSInteger)  x
atY: (NSInteger)  y
withWidth: (NSInteger)  width
withHeight: (NSInteger)  height
andIsInsideFormat: (BOOL)  isInsideFormat
error: (NSError **)  error 

Prints an image from the Apple® mobile digital device's file system to the connected printer as a monochrome image.


Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute.

Parameters
pathFull path to image file. (The image must be either a PNG or JPG).
xHorizontal starting position in dots.
yVertical starting position in dots.
widthDesired width of the printed image. Passing -1 will preserve original width.
heightDesired height of the printed image. Passing -1 will preserve original height.
isInsideFormatBoolean value indicating whether this image should be printed by itself (NO), or is part of a format being written to the connection (YES).
errorWill be set to the error that occured.
Returns
NO if there was an error printing the image.
- (BOOL) storeImage: (NSString *)  printerDriveAndFileName
withImage: (CGImageRef)  image
withWidth: (NSInteger)  width
andWithHeight: (NSInteger)  height
error: (NSError **)  error 

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 (E:FILE.BMP becomes E:FILE.GRF). Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute.

Parameters
printerDriveAndFileNamePath on the printer where the image will be stored.
imageBitmap image to print.
widthDesired width of the printed image, in dots. Passing -1 will preserve original width.
heightDesired height of the printed image, in dots. Passing -1 will preserve original height.
errorWill be set to the error that occured.
Returns
NO if there was an error storing the image.
- (BOOL) storeImage: (NSString *)  printerDriveAndFileName
withPathOnDevice: (NSString *)  imageFilePathOnDevice
withWidth: (NSInteger)  width
andWithHeight: (NSInteger)  height
error: (NSError **)  error 

Stores an image from the Apple® mobile digital device's file system 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). Note: if the image resolution is large (e.g. 1024x768) this method may take a long time to execute.

Parameters
printerDriveAndFileNamePath on the printer where the image will be stored.
imageFilePathOnDevicePath to the file containing the bitmap image to send.
widthDesired width of the printed image, in dots. Passing -1 will preserve original width.
heightDesired height of the printed image, in dots. Passing -1 will preserve original height.
errorWill be set to the error that occured.
Returns
NO if there was an error storing the image.

The documentation for this protocol was generated from the following file: