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
.
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
.
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. 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;
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
.
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
.
closeChannel
Close a session to communicate the printer. You MUST call this when finish your operation and connect to other printers.
Declaration
- (void)closeChannel;