Skip to content

PrinterDriver

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.

Constructors of this class are unavailable. Instead, you have to use PrinterDriverGenerator 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

printImage

Print the image using a print settings.

Declaration

public PrintError printImage(final String path, final PrintSettings printSettings);

Parameters

Name Type Description
path String Filepath to the image.
printSettings PrintSettings Settings to convert the image to binary.

Return Value

See PrintError.

printImage

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

Declaration

public PrintError printImage(final String[] paths, final PrintSettings printSettings);

Parameters

Name Type Description
paths String[] Array of filepaths to the images.
printSettings PrintSettings Settings to convert the images to binary.

Return Value

See PrintError.

printImage

Print the bitmap using a print settings.

Declaration

public PrintError printImage(final Bitmap bitmap, final PrintSettings printSettings);

Parameters

Name Type Description
bitmap Bitmap A pointer to the bitmap.
printSettings PrintSettings Settings to convert the images to binary.

Return Value

See PrintError.

printPDF

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

Declaration

public PrintError printPDF(final String path, final PrintSettings printSettings);

Parameters

Name Type Description
path String Filepath to the PDF.
printSettings PrintSettings Settings to convert the pages to binary.

Return Value

See PrintError.

printPDF

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

Declaration

public PrintError printPDF(final String[] paths, final PrintSettings printSettings);

Parameters

Name Type Description
paths String[] Array of filepaths to the PDFs.
printSettings PrintSettings Settings to convert the images to binary.

Return Value

See PrintError.

printPDF

Print specified pages of the PDF using a print settings.

Declaration

public PrintError printPDF(final String path, final int[] pages, final PrintSettings printSettings);

Parameters

Name Type Description
path String Filepath to the PDF.
pages int[] Page indexes of the PDF.
printSettings PrintSettings Settings to convert the pages to binary.

Return Value

See PrintError.

printTemplate

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

public PrintError printTemplate(final Integer key, final ITemplatePrintSettings printSettings, final ArrayList<TemplateObjectReplacer> replacers)

Parameters

Name Type Description
key Integer Key number assigned to the template. The key starts from 1.
printSettings ITemplatePrintSettings Settings to print template.
replacers ArrayList Info to replace the text in an object of P-touch Template.

Return Value

See PrintError.

sendPRNFile

Send contents of the PRN file.

See also sendRawData.

Declaration

public PrintError sendPRNFile(final String path);

Parameters

Name Type Description
path String Filepath to the PRN file.

Return Value

See PrintError.

sendPRNFile

Send contents of the PRN files.

See also sendRawData.

Declaration

public PrintError sendPRNFile(final String[] paths);

Parameters

Name Type Description
paths String[] Filepaths to the PRN files.

Return Value

See PrintError.

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

public 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

public PrintError sendRawData(final byte[] data);

Parameters

Name Type Description
data byte[] Raw data (e.g. contents of a PRN file).

Return Value

See PrintError.

getPrinterStatus

Get a printer status from the connected printer.

Declaration

public GetStatusResult getPrinterStatus();

Return Value

See GetStatusResult.

requestMainFirmVersion

Get the firmware version of the connected printer.

Declaration

public RequestPrinterInfoResult<String> requestMainFirmVersion();

Return Value

See RequestPrinterInfoResult.

requestMediaVersion

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

Declaration

public RequestPrinterInfoResult<String> requestMediaVersion();

Return Value

See RequestPrinterInfoResult.

requestSerialNumber

Get the serial number of the connected printer.

Declaration

public RequestPrinterInfoResult<String> requestSerialNumber();

Return Value

See RequestPrinterInfoResult.

requestSystemReport

Get the system report of the specified printer.

Declaration

public RequestPrinterInfoResult<String> requestSystemReport();

Return Value

See RequestPrinterInfoResult.

requestBattery

Get the battery info of the specified printer.

Declaration

public RequestPrinterInfoResult<BatteryInfo> requestBatteryInfo();

Return Value

See RequestPrinterInfoResult and BatteryInfo.

requestTemplateInfoList

Get template list of the specified printer.

Declaration

public RequestPrinterInfoResult<ArrayList<PtouchTemplateInfo>> requestTemplateInfoList();

Return Value

See RequestPrinterInfoResult and PtouchTemplateInfo.

closeChannel

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

Declaration

public void closeChannel();