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

closeChannel

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

Declaration

public void closeChannel();

printImage

Print the image using 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 print settings. The settings apply to 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 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.

printImageWithClosures

Print the images using closures and print settings.

Declaration

public PrintError printImageWithClosures(final List<Function0<Bitmap>> closures, final PrintSettings printSettings);

Parameters

Name Type Description
closures List> List of closures that generate bitmaps. The bitmap returned by each closure can be null if there is no image to provide. If null is returned, printing will be interrupted.
printSettings PrintSettings Settings to convert the images to binary.

Return Value

See PrintError.

printPDF

Print the PDF using 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 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 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.

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

getPrinterStatus

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

requestBatteryInfo

Get the battery info of the specified printer.

Declaration

public RequestPrinterInfoResult<BatteryInfo> requestBatteryInfo();

Return Value

See RequestPrinterInfoResult and BatteryInfo.

requestTemplateInfoList

Get the template list of the specified printer.

Declaration

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

Return Value

See RequestPrinterInfoResult and PtouchTemplateInfo.

transferFirmwareFiles

Transfer firmware files to the printer.

Note

When transferring PDZ files, please use the FileConverter class to convert them to PD3 files before transferring.

Declaration

public Transfer.Result<String> transferFirmwareFiles(final List<String> paths, [TransferProgressCallback<String>](#transferprogresscallback) progress);

Parameters

Name Type Description
paths List List of paths to the firmware files.
progress TransferProgressCallback Callback for transfer progress.

Return Value

See Transfer.Result.

transferTemplateFiles

Transfer template files to the printer.

Note

When transferring PDZ files, please use the FileConverter class to convert them to PD3 files before transferring.

Declaration

public Transfer.Result<String> transferTemplateFiles(final List<String> paths, [TransferProgressCallback<String>](#transferprogresscallback) progress);

Parameters

Name Type Description
paths List List of paths to the template files.
progress TransferProgressCallback Callback for transfer progress.

Return Value

See Transfer.Result.

transferDatabaseFiles

Transfer database files to the printer.

Note

When transferring PDZ files, please use the FileConverter class to convert them to PD3 files before transferring.

Declaration

public Transfer.Result<String> transferDatabaseFiles(final List<String> paths, [TransferProgressCallback<String>](#transferprogresscallback) progress);

Parameters

Name Type Description
paths List List of paths to the database files.
progress TransferProgressCallback Callback for transfer progress.

Return Value

See Transfer.Result.

transferBinaryFiles

Transfer binary files to the printer.

Declaration

public Transfer.Result<String> transferBinaryFiles(final List<String> paths, [TransferProgressCallback<String>](#transferprogresscallback) progress);

Parameters

Name Type Description
paths List List of paths to the binary files.
progress TransferProgressCallback Callback for transfer progress.

Return Value

See Transfer.Result.

transferBinaryData

Transfer binary data to the printer.

Declaration

public Transfer.Result<Integer> transferBinaryData(final List<ByteBuffer> data, [TransferProgressCallback<Integer>](#transferprogresscallback) progress);

Parameters

Name Type Description
data List List of binary data buffers.
progress TransferProgressCallback Callback for transfer progress.

Return Value

See Transfer.Result.

Interfaces

TransferProgressCallback

Callback interface for monitoring the progress of a file transfer.

Declaration

public interface TransferProgressCallback<T> {
    void onProgress(T sent, int progressPercentage);
}

Methods

onProgress

Called to report the progress of the file transfer.

Parameters

Name Type Description
sent T The item currently being sent, which matches the type of the transfer argument.
progressPercentage int The percentage of the transfer that has been completed.

Deprecates

Deprecated

sendPRNFile

Please use transferBinaryFiles instead.

sendRawData

Please use transferBinaryData instead.