BRLMPrinterDriver

A Brother Label & Mobile printer driver.

Overview

You use this object to print images and PDFs etc. They are converted to binary data with commands that printers can receive in this class. You also use this to send raw data which you created.

alloc and init of this class are unavailable. Instead, you have to use BRLMPrinterDriverGenerator to instantiate this class.

Caution

You DO NOT use this class in parallel from multiple threads. Methods in this MUST be called on a single thread.

Instance Methods

printImageWithURL:settings:

Print the image using a print settings.

Declaration

- (BRLMPrintError *)printImageWithURL:(NSURL *)url settings:(id<BRLMPrintSettingsProtocol>)settings;

Parameters

Name Type Description
url NSURL * Filepath to the image.
settings id<BRLMPrintSettingsProtocol> Settings to convert the image to binary.

Return Value

See BRLMPrintError.

printImageWithURLs:settings:

Print the images using a print settings. The settings apply every image.

Declaration

- (BRLMPrintError *)printImageWithURLs:(NSArray<NSURL *> *)urls settings:(id<BRLMPrintSettingsProtocol>)settings;

Parameters

Name Type Description
urls NSArray<NSURL *> * Array of filepaths to the images.
settings id<BRLMPrintSettingsProtocol> Settings to convert the images to binary.

Return Value

See BRLMPrintError.

printImageWithImage:settings:

Print the bitmap using a print settings.

Declaration

- (BRLMPrintError *)printImageWithImage:(CGImageRef)imageRef settings:(id<BRLMPrintSettingsProtocol>)settings;

Parameters

Name Type Description
imageRef CGImageRef A pointer to the bitmap.
settings id<BRLMPrintSettingsProtocol> Settings to convert the images to binary.

Return Value

See BRLMPrintError.

printPDFWithURL:settings:

Print the PDF using a print settings. This function prints all pages of the PDF. If you select pages to print, use printPDFWithURL:pages:settings: instead.

Declaration

- (BRLMPrintError *)printPDFWithURL:(NSURL *)url settings:(id<BRLMPrintSettingsProtocol>)settings;

Parameters

Name Type Description
url NSURL * Filepath to the PDF.
settings id<BRLMPrintSettingsProtocol> Settings to convert the pages to binary.

Return Value

See BRLMPrintError.

printPDFWithURLs:settings:

Print the PDFs using a print settings. This function prints all pages of each PDF.

Declaration

- (BRLMPrintError *)printPDFWithURLs:(NSArray<NSURL *> *)urls settings:(id<BRLMPrintSettingsProtocol>)settings;

Parameters

Name Type Description
urls NSArray<NSURL *> * Array of filepaths to the PDFs.
settings id<BRLMPrintSettingsProtocol> Settings to convert the images to binary.

Return Value

See BRLMPrintError.

printPDFWithURL:pages:settings:

Print specified pages of the PDF using a print settings.

Declaration

- (BRLMPrintError *)printPDFWithURL:(NSURL *)url pages:(NSArray<NSNumber *> *)pages settings:(id<BRLMPrintSettingsProtocol>)settings;

Parameters

Name Type Description
url NSURL * Filepath to the PDF.
pages NSArray<NSNumber *> * Page indexes of the PDF.
settings id<BRLMPrintSettingsProtocol> Settings to convert the pages to binary.

Return Value

See BRLMPrintError.

sendPRNFileWithURL:

Send contents of the PRN file.

See also sendRawData.

Declaration

- (BRLMPrintError *)sendPRNFileWithURL:(NSURL *)url;

Parameters

Name Type Description
url NSURL * Filepath to the PRN file.

Return Value

See BRLMPrintError.

sendPRNFileWithURLs:

Send contents of the PRN files.

See also sendRawData.

Declaration

- (BRLMPrintError *)sendPRNFileWithURLs:(NSArray<NSURL *> *)urls;

Parameters

Name Type Description
urls NSArray<NSURL *> * Filepaths to the PRN files.

Return Value

See BRLMPrintError.

cancelPrinting

Cancel sending commands and data to a printer. Actually, this only sets a cancel flag. This printer driver checks the frag when it finishes converting images and sending one image/page. Therefore, this might not work soon and the commands and data that the printer received is not canceled.

Declaration

- (void)cancelPrinting;

sendRawData:

Send raw data to connected printer.

Tip

When using bluetooth, calling closeChannel after this function might cause that not all the data will be send. If you face that problem, call a synchronous process such as getPrinterStatus.

Declaration

- (BRLMPrintError *)sendRawData:(NSData *)data;

Parameters

Name Type Description
data NSData * Raw data (e.g. contents of a PRN file).

Return Value

See BRLMPrintError.

getPrinterStatus

Get a printer status from the connected printer.

Declaration

- (BRLMGetPrinterStatusResult *)getPrinterStatus;

Return Value See BRLMGetPrinterStatusResult.

closeChannel

Close a session to communicate the printer. You MUST call this when finish your operation and connect to other printers.

Declaration

- (void)closeChannel;