Skip to content

PrinterInfo

com.brother.ptouch.sdk.PrinterInfo class manages the settings necessary for performing functions, such as printer name, paper size and print settings.

Instance Methods

setCustomPaperInfo

Set CustomPaperInfo object to configure custom paper information parameters. This is required for RJ/TD series printer. Also refer to the guide for those series.

Declaration

void setCustomPaperInfo(CustomPaperInfo paperInfo);

Parameters

Parameter Description
paperInfo Custom paper infomation parameters.

Properties

printerModel

The model of the printer. Refer to Model.

Declaration

Model printerModel;

port

The kind of the connection interface to the printer. Refer to Port.

Declaration

Port port;

ipAddress

The IP address of the printer. If both ipAddress and macAddress are specified, the SDK try to connect the printer having both identifiers. It results ERROR_NO_MATCH_ADDRESS if there is no matching printer.

Declaration

String ipAddress;

macAddress

The printer's MAC address when port is Port.NET or Bluetooth address when port is Port.BLUETOOTH. See the description of ipAddress for the case both ipAddress and macAddress are specified.

Declaration

String macAddress;

localName

The local name of the printer when port is Port.BLE. (e.g. "RJ-4230B_1234")

Declaration

String localName;

rotation

Image rotation that specifies the angle which your data is placed in the print area. Refer to Rotation. Rotation direction is clockwise.

Declaration

Rotation rotation;

numberofCopies

Number of copies printed.

Declaration

Int numberofCopies;

printMode

The print mode specifies how the image should be scaled. Refer to PrintMode.

Declaration

PrintMode printMode;

scaleValue

The scale value when printMode is PrintMode.SCALE.

Declaration

double scaleValue;

halftone

The method of changing a color or grayscale image to monochrome. Refer to Halftone.

Declaration

Halftone halftone;

thresholdingValue

The threshold value when Halftone is THRESHOLD. The range is from 0 to 255, and the default value is 127.

Declaration

int thresholdingValue;

align

The horizontal alignment to use when printing an image. Ignored when printing a PDF document. Refer to Align.

Declaration

Align align;

valign

The vertical alignment to use when printing an image. Ignored when printing a PDF document. Refer to VAlign.

Declaration

VAlign valign;

margin

The paper margins to use when printing an image. Ignored when printMode is FIT_TO_PAGE or FIT_TO_PAPER. Refer to Margin.

Declaration

Margin margin;

skipStatusCheck

Whether or not to check the status before printing.

Declaration

boolean skipStatusCheck;

checkPrintEnd

Whether or not to check the print-complete status after printing each page. Refer to CheckPrintEnd.

Declaration

CheckPrintEnd checkPrintEnd;

savePrnPath

The absolute path where print data will be saved. The print data will be saved to the file instead of printing if this is not empty string and not null. The default is an empty string. If a folder in the path does not exist, an error occurs.

Declaration

String savePrnPath;

overwrite

Whether the print data will be overwritten or appended to the file when savePrnPath is specified.

Declaration

boolean overwrite;

enabledTethering

Uses to tether the Android device to printer via Wi-Fi connection. This enables getNetPrinters. Follow the instructions below:

  1. Enable the tethering function of the Android device.
  2. Set the AP of the printer connection to the Android device.

Declaration

boolean enabledTethering;

trimTapeAfterData

Trims the blank space at the end of the data after the image is changed to binary/ternary.

Declaration

boolean trimTapeAfterData;

workPath

The working folder the SDK uses internally. The default value is "". You MUST set a path your application has R/W access. To set Scoped Storage(App-specific storage) is recommended.
The SDK makes some temporary files in it when the SDK starts a print/transfer process. After the process, the SDK removes them.

Declaration

String workPath;

paperSize

The paper size used with PJ and MW printers. Refer to PaperSize.

Declaration

PaperSize paperSize;

customPaper

The custom paper information from the file. This is required for RJ/TD series printer. Also refer to the guide for those series.

Declaration

String customPaper;

labelNameIndex

The index number used with an PT or QL printer. Refer to labelNameIndex of LabelInfo class for index number.

Declaration

int labelNameIndex;

pjCarbon

Whether the copy paper mode or not for a PJ printer.

Declaration

boolean pjCarbon;

pjDensity

The density for a PJ printer. The settings range is from 0 (light) to 10 (dark). The default value is 5.

Declaration

int pjDensity;

pjFeedMode

The paper feed mode for a PJ printer. Refer to PjFeedMode.

Declaration

PjFeedMode pjFeedMode;

pjSpeed

The speed for a printer of the PJ series.

Declaration

int pjSpeed;

Constant

Constant Speed
-1 Use Printer Setting
0 high speed
1 medium high speed
2 medium low speed
3 low speed
4 fast draft quality (*1)
5 fast line conversion (*1)
  • (*1) PJ-8xx series only

pjPaperKind

The print area to be used. When PjFeedMode is PJ_FEED_MODE_ENDOFPAGERETRACT, printing is performed in the printing area of the marked roll paper. Refer to PjPaperKind.

Declaration

PjPaperKind pjPaperKind;

forceStretchPrintableArea

Extend the printing area in the bottom direction. Default is 0. Negative values cannot be set. If you use this property, the bottom part of the document may not be printed.

Declaration

int forceStretchPrintableArea;

paperPosition

The feed position for the custom paper. This is valid only when custom paper is used with a PJ series printer. Refer to Align.

Declaration

Align paperPosition;

customPaperWidth

The width of custom paper for a PJ printer. The setting is specified as a multiple of 8 with a maximum of 2464 dots. In addition, the paper feed position is the leftmost LTR line.

Declaration

int customPaperWidth;

customPaperLength

The length of custom paper for a PJ printer. The maximum is 65535 dots, and the minimum is 200 dots.

Declaration

int customPaperLength;

customFeed

The feed amount after printing for PJ series. The value is by dot. This is valid only when PJ_FEED_MODE_FIXEDPAGE is specified.

Declaration

int customFeed;

rollPrinterCase

Specifies the PJ-7xx roll case configuration, which tells the printer how far to feed the paper to position it for tearing off. Refer to PjRollCase.

Declaration

PjRollCase rollPrinterCase;

rjDensity

The density adjustment for the RJ/TD series. The settings range is –5 (light) to 5 (dark). The default value is 0.

Declaration

int rjDensity;

peelMode

Whether to enable the peeler mode or not. This is valid only with a TD equipped with a label peeler or the RJ-3150.

Declaration

boolean peelMode;

isAutoCut

Whether to cut automatically. This is valid only with the QL/PT/TD-4000 series.

Declaration

boolean isAutoCut;

isCutAtEnd

Whether to cut at the end or not. This is valid only with the QL/PT/TD-4000 series. (When in PT series, same meaning as "Chain Print OFF".)

Declaration

boolean isCutAtEnd;

isSpecialTape

Whether it is a special tape or not. This is valid only with the PT series. In addition, when special tape is used, the cutting options become invalid.

Declaration

boolean isSpecialTape;

isHalfCut

Whether to half cut not. This is valid only with the PT series.

Declaration

boolean isHalfCut;

mode9

Whether to compress via Mode 9 or not.

Declaration

boolean mode9;

printQuality

The print quality. Ignored when HS (heat-shrink) or Tube label is selected. Refer to PrintQuality.

Declaration

PrintQuality printQuality;

biColorRedEnhancement

The property for QL-8xx series. Enhancement red color. Value range is from -20 to 20. Default value is 0.
This value is effective when labelNameIndex is value of W62RB.

Declaration

int biColorRedEnhancement;

biColorGreenEnhancement

The property for QL-8xx series. Enhancement green color. Value range is from -20 to 20. Default value is 0.
This value is effective when labelNameIndex is value of W62RB.

Declaration

int biColorGreenEnhancement;

biColorBlueEnhancement

The property for QL-8xx series. Enhancement blue color. Value range is from -20 to 20. Default value is 0.
This value is effective when labelNameIndex is value of W62RB.

Declaration

int biColorBlueEnhancement;

customRecord

A printer records this value with print job when print function works with no error.

The printer must support the custom record function.

Multi-byte characters are not supported. It should be within 64 characters.

Declaration

String customRecord;

Types

Model

The definition of the printer model.

Declaration

enum Model {
    MW_140BT,
    MW_145BT,
    MW_260,
    PJ_522,
    PJ_523,
    PJ_520,
    PJ_560,
    PJ_562,
    PJ_563,
    PJ_622,
    PJ_623,
    PJ_662,
    PJ_663,
    RJ_4030,
    RJ_4040,
    RJ_3150,
    RJ_3050,
    QL_580N,
    QL_710W,
    QL_720NW,
    TD_2020,
    TD_2120N,
    TD_2130N,
    PT_E550W,
    PT_P750W,
    TD_4100N,
    TD_4000,
    PJ_762,
    PJ_763,
    PJ_773,
    PJ_722,
    PJ_723,
    PJ_763MFi,
    MW_145MFi,
    MW_260MFi,
    PT_E850TKW,
    PT_D800W,
    PT_P900W,
    PT_P950NW,
    RJ_4030Ai,
    PT_E800W,
    RJ_2030,
    RJ_2050,
    RJ_2140,
    RJ_2150,
    RJ_3050Ai,
    RJ_3150Ai,
    QL_800,
    QL_810W,    //Can be use for QL-810Wc
    QL_820NWB,  //Can be use for QL-820NWBc
    QL_1100,    //Can be use for QL-1110c
    QL_1110NWB, //Can be use for QL-1110NWBc
    QL_1115NWB,
    PT_E500,
    RJ_4230B,
    RJ_4250WB,
    TD_4410D,
    TD_4420DN,
    TD_4510D,
    TD_4520DN,
    TD_4550DNWB,
    MW_170,
    MW_270,
    PT_P910BT,
    RJ_3230B,
    RJ_3250WB,
    PJ_822,
    PJ_823,
    PJ_862,
    PJ_863,
    PJ_883,
    TD_2030A,
    TD_2125N,
    TD_2125NWB,
    TD_2135N,
    TD_2135NWB,
    PT_E310BT,
    PT_E510,
    PT_E560BT,
    TD_2310D_203,
    TD_2310D_300,
    TD_2320D_203,
    TD_2320D_300,
    TD_2320DF_203,
    TD_2320DF_300,
    TD_2320DSA_203,
    TD_2320DSA_300,
    TD_2350D_203,
    TD_2350D_300,
    TD_2350DF_203,
    TD_2350DF_300,
    TD_2350DSA_203,
    TD_2350DSA_300,
    TD_2350DFSA_203,
    TD_2350DFSA_300,
}

Port

The definition of the kind of the connection interface to the printer.

Declaration

enum Port {
    USB,
    BLUETOOTH,
    NET,
    BLE,
}

Orientation

The definition of the paper orientation.

Declaration

enum Orientation {
    PORTRAIT,
    LANDSCAPE,
}

Rotation

The definition of the image angle by degree.

Declaration

enum PrintMode {
    Rotate0,
    Rotate90,
    Rotate180,
    Rotate270,
}

PrintMode

The definition of the image scaling.

Declaration

enum PrintMode {
    /* No scaling.
       You need to prepare data less than or equal to the printable area.
       Refer to the raster command reference for each model to know the area */
    ORIGINAL,

    /* Reduces or enlarges the image to fit to the printing area
       keeping the aspect ratio */
    FIT_TO_PAGE,

    // Scale the image using scaleValue
    SCALE,

    /* Reduces or enlarges the image to fit to the paper
       keeping the aspect ratio */
    FIT_TO_PAPER,
}

Halftone

The definition of the method of changing a color or grayscale image to monochrome

Declaration

enum Halftone {
    THRESHOLD,      // Threshold
    PATTERNDITHER,  // Pattern dither
    ERRORDIFFUSION, // Error diffusion
}

Align

The definition of the horizontal alignment.

Declaration

enum Align {
    LEFT,
    CENTER,
    RIGHT,
}

VAlign

The definition of the vertical alignment.

Declaration

enum VAlign {
    TOP,
    MIDDLE,
    BOTTOM,
}

Margin

The margin.

Declaration

class Margin {
    int left;
    int top;
}

CheckPrintEnd

The definition of checking the print-complete status after printing each page.

Declaration

enum CheckPrintEnd {
    CPE_NO_CHECK,  // Not check the complete status of all pages
    CPE_SKIP_LAST, // Check the complete status other than the last page
    CPE_CHECK,     // Check the complete status of all pages
}

PaperSize

The definition of the paper size for PJ and MW printers.

Declaration

enum PaperSize {
    CUSTOM,
    A7,
    A6,
    A4,
    A5,
    A5_LANDSCAPE,
    LETTER,
    LEGAL,
}

PjFeedMode

The definition of the paper feed mode for a PJ printer.

Declaration

enum PjFeedMode {
    PJ_FEED_MODE_FREE,             // No feed for roll papers.
    PJ_FEED_MODE_FIXEDPAGE,        // Fixed page size feed for roll papers
    PJ_FEED_MODE_ENDOFPAGE,        // A page feed for cut-sheet papers
    PJ_FEED_MODE_ENDOFPAGERETRACT, // A page feed for roll papers with mark (Letter size only)
}

PjPaperKind

The definition of the paper kind for a PJ printer.

Declaration

enum PjPaperKind {
    PJ_ROLL,      // Roll paper
    PJ_CUT_PAPER, // Cut-sheet paper
}

PjRollCase

The definition of the PJ-7xx roll case.

Declaration

enum PjRollCase {
    PJ_ROLLCASE_OFF,                    // No roll case is used
    PJ_ROLLCASE_ON,                     // Roll case without anti curl
    PJ_ROLLCASE_WITH_ANTICURL,          // Roll case with anti curl
    PJ_ROLLCASE_SHORT_FEED,             // Set short feed mode
    PJ_ROLLCASE_KEEP_PRINTER_SETTING;   // Keep printer setting
}

PrintQuality

The definition of the print quality for PT, QL and TD series.

Declaration

enum PrintQuality {
    LOW_RESOLUTION,  // Prints with the half resolution in the print direction
    NORMAL,          // Normal
    DOUBLE_SPEED,    // Resolution without changing performs printing by raising the printing speed
    HIGH_RESOLUTION, // Prints with the double resolution in the print direction
}

Supported printers for each enumerator are as below.

Enumerator Supported Printer
LOW_RESOLUTION PT-E850TKW, PT-D800W, PT-E800W, PT-P900W, PT-P950NW
NORMAL QL series, PT series, TD series
DOUBLE_SPEED QL series, TD-2XXX series
HIGH_RESOLUTION QL series (other than QL-11xx series), PT series

ErrorCode

The definition of error codes.

Declaration

enum ErrorCode {
    // No error
    ERROR_NONE,

    // Found a different printer model than expected
    ERROR_NOT_SAME_MODEL,

    // Cannot find a Brother printer
    ERROR_BROTHER_PRINTER_NOT_FOUND,

    // Paper empty
    ERROR_PAPER_EMPTY,

    // Battery weak
    ERROR_BATTERY_EMPTY,

    // Failed to retrieve printer status
    ERROR_COMMUNICATION_ERROR,

    // Print-head overheated
    ERROR_OVERHEAT,

    // Paper jam                      
    ERROR_PAPER_JAM,

    // High-voltage adapter
    ERROR_HIGH_VOLTAGE_ADAPTER,

    // Paper cassette change while printing
    ERROR_CHANGE_CASSETTE,

    // Feed error or paper cassette empty
    ERROR_FEED_OR_CASSETTE_EMPTY,

    // System error
    ERROR_SYSTEM_ERROR,

    // No paper-cassette
    ERROR_NO_CASSETTE,

    // Paper-cassette loaded incorrectly
    ERROR_WRONG_CASSETTE_DIRECT,

    // Failed to create socket
    ERROR_CREATE_SOCKET_FAILED,

    /* Failed to connect:
     * For MW-140BT and MW-260/MW-260 Type A, 
     * disabling the PIN code may resolve this error. */
    ERROR_CONNECT_SOCKET_FAILED,

    // Failed to open output stream
    ERROR_GET_OUTPUT_STREAM_FAILED,

    // Failed to open input stream
    ERROR_GET_INPUT_STREAM_FAILED,

    // Failed to close socket
    ERROR_CLOSE_SOCKET_FAILED,

    /* Insufficient memory:
     * Reduce the image size. */
    ERROR_OUT_OF_MEMORY,

    /* Image size exceeds margin setting:
     * Reduce margins and/or image size until the image fits. */
    ERROR_SET_OVER_MARGIN,

    // No SD card
    ERROR_NO_SD_CARD,

    // Unsupported file type
    ERROR_FILE_NOT_SUPPORTED,

    // PDF library trial period expired
    ERROR_EVALUATION_TIMEUP,

    // Wrong information in custom paper setting file
    ERROR_WRONG_CUSTOM_INFO,

    // IP and/or MAC address not set
    ERROR_NO_ADDRESS,

    // No printer found with the expected IP and/or MAC address
    ERROR_NOT_MATCH_ADDRESS,

    // File does not exist
    ERROR_FILE_NOT_FOUND,

    // Printer model in template file does not match selected printer
    ERROR_TEMPLATE_FILE_NOT_MATCH_MODEL,

    // Selected printer model does not support Template transfer
    ERROR_TEMPLATE_NOT_TRANS_MODEL,

    // Cover is open (RJ/TD/PT-E550W)
    ERROR_COVER_OPEN,

    // Wrong media type
    ERROR_WRONG_LABEL,

    // Unsupported interface
    ERROR_PORT_NOT_SUPPORTED,

    // No file exists with the specified template key
    ERROR_WRONG_TEMPLATE_KEY,

    // Busy (PT series/RJ-3xxx/TD-4xxx)
    ERROR_BUSY,

    // Selected printer model does not support Template printing
    ERROR_TEMPLATE_NOT_PRINT_MODEL,

    // Printing has been cancelled
    ERROR_CANCEL,

    // Selected printer does not support device setting
    ERROR_PRINTER_SETTING_NOT_SUPPORTED,

    // Invalid parameter value
    ERROR_INVALID_PARAMETER,

    // Internal error
    ERROR_INTERNAL_ERROR,

    // Print model does not support template list or remove operation
    ERROR_TEMPLATE_NOT_CONTROL_MODEL,

    // Template not found in selected printer
    ERROR_TEMPLATE_NOT_EXIST,

    // Buffer full
    ERROR_BUFFER_FULL,

    // Tube empty
    ERROR_TUBE_EMPTY,

    // Tube ribbon empty
    ERROR_TUBE_RIBBON_EMPTY,

    // Unsupported OS version
    ERROR_OS_VERSION_NOT_SUPPORTED,

    /* High-resolution / draft printing error:
     * You can not use the high-resolution / high-speed printing.
     * Change the print settings to a standard or use the AC adapter. */
    ERROR_RESOLUTION_MODE,

    // AC adapter or disconnect error
    ERROR_POWER_CABLE_UNPLUGGING,

    /* Battery error:
     * Replace to a new battery or use a proper AC adapter */
    ERROR_BATTERY_TROUBLE,

    /* Unsupported media error:
     * Attach a corresponding cassette properly */
    ERROR_UNSUPPORTED_MEDIA,

    // Tube cutter of the P-touch does not work
    ERROR_TUBE_CUTTER,

    // The paper set inside is not compatible with two-color printing
    ERROR_UNSUPPORTED_TWO_COLOR,

    // The paper set inside is not compatible with monochrome printing
    ERROR_UNSUPPORTED_MONO_COLOR,

    // Print data length is too short
    ERROR_MINIMUM_LENGTH_LIMIT,

    // PrinterInfo.workPath is not set
    ERROR_WORKPATH_NOT_SET,

    // The USB connected has not enough power supply capacity to print
    ERROR_UNSUPPORTED_USB_CHARGER,

    // The optional equipment is not compatible with the printer.
    ERROR_UNSUPPORTED_OPTIONAL_EQUIPMENT,
}

Msg

The definition of messages the SDK sends while printing.

Declaration

enum Msg {
    // Communication starting
    MESSAGE_START_COMMUNICATION,

    // Socket connection started
    MESSAGE_START_CONNECT,

    // Socket connection successful
    MESSAGE_END_CONNECTED,

    // Opening an output stream
    MESSAGE_START_GET_OUTPUT_STREAM,

    // Output stream opened
    MESSAGE_END_GET_OUTPUT_STREAM,

    // Opening an input stream
    MESSAGE_START_GET_INPUT_STREAM,

    // Input stream opened
    MESSAGE_END_GET_INPUT_STREAM,

    // Start transmitting status request
    MESSAGE_START_SEND_STATUS_REQUEST,

    // Status request transmitted
    MESSAGE_END_SEND_STATUS_REQUEST,

    // Start receiving printer status
    MESSAGE_START_READ_PRINTER_STATUS,

    // Printer status received
    MESSAGE_END_READ_PRINTER_STATUS,

    // Start creating data
    MESSAGE_START_CREATE_DATA,

    // Data creation finished
    MESSAGE_END_CREATE_DATA,

    // Start transmitting data
    MESSAGE_START_SEND_DATA,

    // Data transmission complete
    MESSAGE_END_SEND_DATA,

    // Start transmitting template file
    MESSAGE_START_SEND_TEMPLATE,

    // Template file transmission complete
    MESSAGE_END_SEND_TEMPLATE,

    // Start socket disconnection
    MESSAGE_START_SOCKET_CLOSE,

    // Socket disconnected
    MESSAGE_END_SOCKET_CLOSE,

    // Communication finished
    MESSAGE_END_COMMUNICATION,

    // Print success
    MESSAGE_PRINT_COMPLETE,

    // An error occurred
    MESSAGE_PRINT_ERROR,

    // Paper empty
    MESSAGE_PAPER_EMPTY,

    // Cooling start
    MESSAGE_START_COOLING,

    // Cooling end
    MESSAGE_END_COOLING,

    // Wait for label to get through peeler
    MESSAGE_WAIT_PEEL,

    // Start Bluetooth settings update
    MESSAGE_START_UPDATE_BLUETOOTH_SETTING,

    // Bluetooth settings update complete
    MESSAGE_END_UPDATE_BLUETOOTH_SETTING,

    // Start getting Bluetooth setting
    MESSAGE_START_GET_BLUETOOTH_SETTING,

    // Bluetooth settings retrieval complete
    MESSAGE_END_GET_BLUETOOTH_SETTING,

    // Start getting the template list
    MESSAGE_START_GET_TEMPLATE_LIST,

    // Template list retrieval complete
    MESSAGE_END_GET_TEMPLATE_LIST,

    // Start templates removal process
    MESSAGE_START_REMOVE_TEMPLATE_LIST,

    // Template removal complete
    MESSAGE_END_REMOVE_TEMPLATE_LIST,

    // Cancel
    MESSAGE_CANCEL,
}

Notes

Property Compatibility

Some properties of PrinterInfo are supported only by specific printers. Refer to the compatibility table.

Deprecates

Deprecated

orientation

Please use rotation instead.

rotate180

Please use rotation instead.