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

This is a utility class for performing file operations on a printer. More...

#import <FileUtil.h>

Instance Methods

(BOOL) - sendFileContents:error:
 Sends the contents of a file to the printer.
 
(NSArray *) - retrieveFileNames:
 Retrieves the names of the files which are stored on the printer.
 
(NSArray *) - retrieveFileNamesWithExtensions:error:
 Retrieves the names of the files which are stored on the printer.
 

Detailed Description

This is a utility class for performing file operations on a printer.

Send file contents to a printer:

    @code 

#import "TcpPrinterConnection.h" #import <UIKit/UIKit.h> #import "ZebraPrinter.h" #import "ZebraPrinterFactory.h"

TcpPrinterConnection *zebraPrinterConnection = [[TcpPrinterConnection alloc] initWithAddress:"192.168.1.101" andWithPort:6101]; [zebraPrinterConnection open]; NSError *error = nil; id<ZebraPrinter,NSObject> printer = [ZebraPrinterFactory getInstance:zebraPrinterConnection error:&error]; // If SAMPLE.FMT contains a CPCL format, it will be printed

BOOL success = [[printer getFileUtil] sendFileContents:"/Documents/SAMPLE.FMT" error:&error];

if (error != nil || success == NO || printer == nil) { UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [errorAlert show]; [errorAlert release]; }

[zebraPrinterConnection close]; [zebraPrinterConnection release];

Get directory listing from a printer:

#import "TcpPrinterConnection.h"
#import <UIKit/UIKit.h>
#import "ZebraPrinter.h"
#import "ZebraPrinterFactory.h"
TcpPrinterConnection *zebraPrinterConnection = [[TcpPrinterConnection alloc] initWithAddress:@"192.168.1.101" andWithPort:6101];
BOOL success = [zebraPrinterConnection open];
NSError *error = nil;
id<ZebraPrinter,NSObject> printer = [ZebraPrinterFactory getInstance:zebraPrinterConnection error:&error];
// Get a list of the files on the printer
NSArray *fileNames = [[printer getFileUtil] retrieveFileNames:&error];
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];
}
NSLog(@"Number of files - %d", [fileNames count]);
[zebraPrinterConnection close];
[zebraPrinterConnection release];

Method Documentation

- (NSArray*) retrieveFileNames: (NSError **)  error

Retrieves the names of the files which are stored on the printer.

Parameters
errorWill be set to the error that occured.
Returns
A list of file names.
- (NSArray*) retrieveFileNamesWithExtensions: (NSArray *)  extensions
error: (NSError **)  error 

Retrieves the names of the files which are stored on the printer.

This method only returns files which have the extensions in extensions.

Parameters
extensionsThe extensions to filter on.
errorWill be set to the error that occured.
Returns
A list of file names.
- (BOOL) sendFileContents: (NSString *)  filePath
error: (NSError **)  error 

Sends the contents of a file to the printer.

Parameters
filePathThe full file path (e.g. @"/Documents/sample.txt").
errorWill be set to the error that occured.
Returns
NO if there was an error sending the contents.

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