Skip to content

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

closeChannel

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

Declaration

- (void)closeChannel;

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.

printImageWithClosures:settings:

Print images using closures and print settings.

Declaration

- (BRLMPrintError *)printImageWithClosures:(NSArray<BRLMPrinterDriverPrintImageClosure>*)closures settings:(id<BRLMPrintSettingsProtocol>)settings NS_REFINED_FOR_SWIFT;

Parameters

Name Type Description
closures NSArray<BRLMPrinterDriverPrintImageClosure>* Array of closures to provide images.
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.

printTemplateWithKey:settings:replacers:

Print installed P-touch Template with specified data. This function assumes the default P-touch Template settings. Your application may not be able to print if the printer's settings differ from the defaults. If necessary, use the P-touch Template Setting Tool to configure the printer.

Declaration

- (BRLMPrintError *)printTemplateWithKey:(NSUInteger)key settings:(id<BRLMTemplatePrintSettingsProtocol>)settings replacers:(NSArray<BRLMTemplateObjectReplacer *>*)replacers

Parameters

Name Type Description
key NSUInteger Key number assigned to the template. The key starts from 1.
settings id<BRLMTemplatePrintSettingsProtocol> Settings to print template.
replacers NSArray<BRLMTemplateObjectReplacer *> * Info to replace the text in an object of P-touch Template.

Return Value

See BRLMPrintError.

cancelPrinting

Cancel sending commands and data to a printer. Actually, this only sets a cancel flag. The printer driver checks the flag when it finishes converting images and sending one image/page to the printer. Therefore, it will only cancel the printing if the cancel flag is set before the print driver checks.

Declaration

- (void)cancelPrinting;

getPrinterStatus

Get a printer status from the connected printer.

Declaration

- (BRLMGetPrinterStatusResult *)getPrinterStatus;

Return Value

See BRLMGetPrinterStatusResult.

requestMainFirmVersion

Get the firmware version of the connected printer.

Declaration

- (BRLMRequestPrinterInfoResult<NSString *> *)requestMainFirmVersion;

Return Value

See BRLMRequestPrinterInfoResult.

requestMediaVersion

Get the media version in the firmware of the connected printer.

Declaration

- (BRLMRequestPrinterInfoResult<NSString *> *)requestMediaVersion;

Return Value

See BRLMRequestPrinterInfoResult.

requestSerialNumber

Get the serial number of the connected printer.

Declaration

- (BRLMRequestPrinterInfoResult<NSString *> *)requestSerialNumber;

Return Value

See BRLMRequestPrinterInfoResult.

requestSystemReport

Get the system report of the specified printer.

Declaration

- (BRLMRequestPrinterInfoResult<NSString *> *)requestSystemReport;

Return Value

See BRLMRequestPrinterInfoResult.

requestBattery

Get the battery info of the specified printer.

Declaration

- (BRLMRequestPrinterInfoResult<BRLMBatteryInfo *> *)requestBatteryInfo

Return Value

See BRLMRequestPrinterInfoResult and BRLMBatteryInfo.

requestTemplateInfoList

Get template list of the specified printer.

Declaration

- (BRLMRequestPrinterInfoResult<NSMutableArray<BRLMPtouchTemplateInfo*> *> *) requestTemplateInfoList

Return Value

See BRLMRequestPrinterInfoResult and BRLMPtouchTemplateInfo.

transferFirmwareFiles:progress:

Transfer firmware files to the printer.

Declaration

- (BRLMTransferResult<NSURL*> *)transferFirmwareFiles:(NSArray<NSURL *> *)urls progress:(void (^)(NSURL* current, int progress))progress;

Parameters

Name Type Description
urls NSArray<NSURL *> * List of paths to the firmware files.
progress void (^progress)(NSURL* current, int progress) Callback for transfer progress. current is the item currently being transferred, which matches the value of urls. progress is the percentage of the transfer that has been completed.

Return Value

See BRLMTransferResult.

transferTemplateFiles:progress:

Transfer template files to the printer.

Declaration

- (BRLMTransferResult<NSURL*> *)transferTemplateFiles:(NSArray<NSURL *> *)urls progress:(void (^)(NSURL* current, int progress))progress;

Parameters

Name Type Description
urls NSArray<NSURL *> * List of paths to the template files.
progress void (^progress)(NSURL* current, int progress) Callback for transfer progress. current is the item currently being transferred, which matches the value of urls. progress is the percentage of the transfer that has been completed.

Return Value

See BRLMTransferResult.

transferDatabaseFiles:progress:

Transfer database files to the printer.

Declaration

- (BRLMTransferResult<NSURL*> *)transferDatabaseFiles:(NSArray<NSURL *> *)urls progress:(void (^)(NSURL* current, int progress))progress;

Parameters

Name Type Description
urls NSArray<NSURL *> * List of paths to the database files.
progress void (^progress)(NSURL* current, int progress)) Callback for transfer progress. current is the item currently being transferred, which matches the value of urls. progress is the percentage of the transfer that has been completed.

Return Value

See BRLMTransferResult.

transferBinaryFiles:progress:

Transfer binary files to the printer.

Declaration

- (BRLMTransferResult<NSURL*> *)transferBinaryFiles:(NSArray<NSURL *> *)urls progress:(void (^)(NSURL* current, int progress))progress;

Parameters

Name Type Description
urls NSArray<NSURL *> * List of paths to the binary files.
progress void (^progress)(NSURL* current, int progress) Callback for transfer progress. current is the item currently being transferred, which matches the value of urls. progress is the percentage of the transfer that has been completed.

Return Value

See BRLMTransferResult.

transferBinaryData:progress:

Transfer binary data to the printer.

Declaration

- (BRLMTransferResult<NSNumber*> *)transferBinaryData:(NSArray<NSData *> *)data progress:(void (^)(NSNumber* index, int progress))progress;

Parameters

Name Type Description
data NSArray<NSData *> * List of binary data buffers.
progress void (^progress)(NSNumber* index, int progress) Callback for transfer progress. current is the item currently being transferred, which matches the value of data. progress is the percentage of the transfer that has been completed.

Return Value

See BRLMTransferResult.

Types

BRLMPrinterDriverPrintImageClosure

This block type is used in methods such as printImageWithClosures:settings: to provide images for printing.

Declaration

typedef _Nullable CGImageRef (^BRLMPrinterDriverPrintImageClosure)(void);

Parameters

This block type does not take any parameters.

Return Value

  • CGImageRef: A pointer to a Core Graphics image. The returned image can be null if there is no image to provide. If null is returned, printing will be interrupted.

Deprecates

Deprecated

sendPRNFileWithURL:

Please use transferBinaryFiles:progress: instead.

sendPRNFileWithURLs:

Please use transferBinaryFiles:progress: instead.

sendRawData:

Please use transferBinaryData:progress: instead.