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.

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. 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

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.

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();