Skip to content

About

Capacitor plugin for Brother Print SDK

Resources

Contributing

Security policy

Stars

27 stars

Watchers

2 watching

Forks

Repository files navigation

@rdlabo/capacitor-brotherprint

Capacitor Brother Print binds the native Brother Print SDK for iOS and Android so you can search supported Brother label printers and print images from a Capacitor app.

This plugin is still in the RC (release candidate) phase. iOS requires Swift Package Manager and a minimum of iOS 15. The Brother Print SDK is not compatible with CocoaPods for this plugin.

Documentation: Read the full documentation

Install

npm install @rdlabo/capacitor-brotherprint

For SDK placement, SPM layout, and permissions, see Installation.

Print your first label

  1. Installation — npm install, place the Brother SDK, permissions, then npx cap sync.
  2. Search — register onPrinterAvailable, keep the discovered channel, run Wi-Fi (or other) search.
  3. Print — print with that channel, a supported model/label, and a real base64 image you prepare.
  4. Events — print success and error listeners in more detail.

Supported models

Each product link is an Amazon affiliate link. Purchases through these links help support development costs.

Product Model iOS/WiFi iOS/BT iOS/BLE Android/USB Android/WiFi Android/BT Android/BLE
QL-810W QL_810W ❌ ❌ ❌ ✅ ❌ ❌ ❌
QL-820NWB QL_820NWB ✅ ※1 ❌ △ ✅ △ ❌
QL-820NWBc QL_820NWB ✅ ✅ ❌ ❌ ✅ ✅ ❌
TD-2320D TD_2320D_203 ❌ ❌ ❌ △ ❌ ❌ ❌
TD-2350D TD_2350D_300 ✅ △ △ ✅ ✅ ✅ △

Amazon Affiliate Links: https://amzn.to/3AiiOFT

Supplement

description
✅ Supported and tested
△ Implemented but not tested
- Plugin is not supported
❌ Device is not supported
BT Bluetooth
BLE Bluetooth Low Energy

※1 Due to low Bluetooth version, connection is not possible with iOS. Ref: https://okbizcs.okwave.jp/brother/qa/q9932082.html

JavaScript helpers

BrotherPrinterSession owns a print screen's discovery results, print listeners and shutdown. Pure functions provide model/connection choices, and stateless connection helpers remain available. None require Angular or Ionic. See connection management for usage.

API

printImage(...)

printImage(options: BRLMPrintOptions) => Promise<void>
Param Type
options BRLMPrintOptions

search(...)

search(option: BRLMSearchOption) => Promise<void>

Search for printers. If not found, it will return an empty array.(not error)

Param Type
option BRLMSearchOption

isChannelAvailable(...)

isChannelAvailable(option: BRLMChannelResult) => Promise<isChannelAvailableResult>

If you have saved the last connected BRLMChannelResult, you can use it to verify whether it is currently usable.

Param Type
option BRLMChannelResult

Returns: Promise<isChannelAvailableResult>


cancelSearchWiFiPrinter()

cancelSearchWiFiPrinter() => Promise<void>

Stop an active search before its timeout, including when leaving the screen.


cancelSearchBluetoothPrinter()

cancelSearchBluetoothPrinter() => Promise<void>

Stop an active search before its timeout, including when leaving the screen.


addListener(BrotherPrintEventsEnum.onPrinterAvailable, ...)

addListener(eventName: BrotherPrintEventsEnum.onPrinterAvailable, listenerFunc: (printers: BRLMChannelResult) => void) => Promise<PluginListenerHandle>

Find the printer that can connected to the device.

Param Type
eventName BrotherPrintEventsEnum.onPrinterAvailable
listenerFunc (printers: BRLMChannelResult) => void

Returns: Promise<PluginListenerHandle>


addListener(BrotherPrintEventsEnum.onPrint, ...)

addListener(eventName: BrotherPrintEventsEnum.onPrint, listenerFunc: () => void) => Promise<PluginListenerHandle>

Success Print Event

Param Type
eventName BrotherPrintEventsEnum.onPrint
listenerFunc () => void

Returns: Promise<PluginListenerHandle>


addListener(BrotherPrintEventsEnum.onPrintFailedCommunication, ...)

addListener(eventName: BrotherPrintEventsEnum.onPrintFailedCommunication, listenerFunc: (info: ErrorInfo) => void) => Promise<PluginListenerHandle>

Failed to connect to the printer. ex: Bluetooth is off, Printer is off, etc.

Param Type
eventName BrotherPrintEventsEnum.onPrintFailedCommunication
listenerFunc (info: ErrorInfo) => void

Returns: Promise<PluginListenerHandle>


addListener(BrotherPrintEventsEnum.onPrintError, ...)

addListener(eventName: BrotherPrintEventsEnum.onPrintError, listenerFunc: (info: ErrorInfo) => void) => Promise<PluginListenerHandle>

Failed to print.

Param Type
eventName BrotherPrintEventsEnum.onPrintError
listenerFunc (info: ErrorInfo) => void

Returns: Promise<PluginListenerHandle>


Interfaces

PluginListenerHandle

Prop Type
remove () => Promise<void>

Type Aliases

BRLMPrintOptions

{ encodedImage: string; /** * Should use enum BRLMPrinterModelName */ modelName: BRLMPrinterModelName; } & Partial<BRLMChannelResult> & (BRLMPrinterQLModelSettings | BRLMPrinterTDModelSettings)

Partial

Make all properties in T optional

{ [P in keyof T]?: T[P]; }

BRLMChannelResult

{ port: BRLMPrinterPort; modelName: string; serialNumber: string; macAddress: string; nodeName: string; location: string; /** * This need to connect to the printer. * wifi: IP Address * bluetooth: macAddress * bluetoothLowEnergy: modelName for bluetoothLowEnergy */ channelInfo: string; }

BRLMPrinterQLModelSettings

{ /** * Should use enum BRLMPrinterLabelName */ labelName: BRLMPrinterLabelName; } & BRLMPrinterSettings

BRLMPrinterSettings

These are optional. If these are not set, default values are assigned by the printer.

{ /** * The number of copies you print. / numberOfCopies?: BRLMPrinterNumberOfCopies; /* * Whether the auto-cut is enabled or not. If true, your printer cut the paper each page. / autoCut?: BRLMPrinterAutoCutType; /* * A scale mode that specifies how your data is scaled in a print area of your printer. / scaleMode?: BRLMPrinterScaleMode; /* * A scale value. This is effective when ScaleMode is ScaleValue. / scaleValue?: BRLMPrinterScaleValueType; /* * A way to rasterize your data. / halftone?: BRLMPrinterHalftone; /* * A threshold value. This is effective when the Halftone is Threshold. / halftoneThreshold?: BRLMPrinterHalftoneThresholdType; /* * An image rotation that specifies the angle in which your data is placed in the print area. Rotation direction is clockwise. / imageRotation?: BRLMPrinterImageRotation; /* * A vertical alignment that specifies how your data is placed in the printable area. / verticalAlignment?: BRLMPrinterVerticalAlignment; /* * A horizontal alignment that specifies how your data is placed in the printable area. / horizontalAlignment?: BRLMPrinterHorizontalAlignment; /* * A compress mode that specifies how to compress your data. * note: This is ios only. / compressMode?: BRLMPrinterCompressMode; /* * A priority that is print speed or print quality. Whether or not this has an effect is depend on your printer. */ printQuality?: BRLMPrinterPrintQuality; }

BRLMPrinterNumberOfCopies

number

BRLMPrinterAutoCutType

boolean

BRLMPrinterScaleValueType

number

BRLMPrinterHalftoneThresholdType

number

BRLMPrinterTDModelSettings

{ /** * Should use enum BRKMPrinterCustomPaperType / paperType: BRLMPrinterCustomPaperType; /* * The width of the label. For example, the RD-U04J1 is 60.0 wide. / tapeWidth: number; /* * The length of the label. For example, the RD-U04J1 is 60.0 wide. / tapeLength: number; /* * It is the difference between a sticker and a mount. * For example, the RD-U04J1 is 1.0, 2.0, 1.0, 2.0 / marginTop: number; marginRight: number; marginBottom: number; marginLeft: number; /* * The spacing between seals. For example, the RD-U04J1 is 0.2. / gapLength: number; paperMarkPosition: number; paperMarkLength: number; /* * Should use enum BRKMPrinterCustomPaperUnit. * For example, the RD-U04J1 is mm. */ paperUnit: BRLMPrinterCustomPaperUnit; }

BRLMSearchOption

{ /** * 'usb' is android only, and now developing. / port: BRLMPrinterPort; /* * searchDuration is the time to end search for devices. * default is 15 seconds. * Used for Wi-Fi, BLE, and the iOS Bluetooth accessory picker wait. * Timing out does not dismiss the system accessory picker; close it before retrying. / searchDuration: number; /* * Android Bluetooth Classic only. Include only devices whose Bluetooth class * reports a printer. Defaults to false; ignored for other ports and on iOS. * This does not identify Brother devices. Devices with an unknown class are excluded when true. */ bluetoothPrintersOnly?: boolean; }

isChannelAvailableResult

{ result: boolean; }

ErrorInfo

{ message: string; code: number; }

Enums

BRLMPrinterModelName

Members Value
QL_800 'QL_800'
QL_810W 'QL_810W'
QL_820NWB 'QL_820NWB'
TD_2320D_203 'TD_2320D_203'
TD_2030AD 'TD_2030AD'
TD_2350D_300 'TD_2350D_300'

BRLMPrinterPort

Members Value
usb 'usb'
wifi 'wifi'
bluetooth 'bluetooth'
bluetoothLowEnergy 'bluetoothLowEnergy'

BRLMPrinterLabelName

Members Value Description
DieCutW17H54 'DieCutW17H54'
DieCutW17H87 'DieCutW17H87'
DieCutW23H23 'DieCutW23H23'
DieCutW29H42 'DieCutW29H42'
DieCutW29H90 'DieCutW29H90'
DieCutW38H90 'DieCutW38H90'
DieCutW39H48 'DieCutW39H48'
DieCutW52H29 'DieCutW52H29'
DieCutW62H29 'DieCutW62H29'
DieCutW62H60 'DieCutW62H60'
DieCutW62H75 'DieCutW62H75'
DieCutW62H100 'DieCutW62H100'
DieCutW60H86 'DieCutW60H86'
DieCutW54H29 'DieCutW54H29'
DieCutW102H51 'DieCutW102H51'
DieCutW102H152 'DieCutW102H152'
DieCutW103H164 'DieCutW103H164'
RollW12 'RollW12'
RollW29 'RollW29'
RollW38 'RollW38'
RollW50 'RollW50'
RollW54 'RollW54'
RollW62 'RollW62'
RollW62RB 'RollW62RB'
RollW102 'RollW102'
RollW103 'RollW103'
DTRollW90 'DTRollW90'
DTRollW102 'DTRollW102'
DTRollW102H51 'DTRollW102H51'
DTRollW102H152 'DTRollW102H152'
RoundW12DIA 'RoundW12DIA'
RoundW24DIA 'RoundW24DIA'
RoundW58DIA 'RoundW58DIA'
RDDieCutW60H60 'RDDieCutW60H60' For TD series
RDDieCutW50H30 'RDDieCutW50H30'
RDDieCutW40H60 'RDDieCutW40H60'
RDDieCutW40H50 'RDDieCutW40H50'
RDDieCutW40H40 'RDDieCutW40H40'
RDDieCutW30H30 'RDDieCutW30H30'
RDDieCutW50H35 'RDDieCutW50H35'
RDDieCutW60H80 'RDDieCutW60H80'
RDDieCutW60H100 'RDDieCutW60H100'

BRLMPrinterScaleMode

Members Value
ActualSize 'ActualSize'
FitPageAspect 'FitPageAspect'
FitPaperAspect 'FitPaperAspect'
ScaleValue 'ScaleValue'

BRLMPrinterHalftone

Members Value
Threshold 'Threshold'
ErrorDiffusion 'ErrorDiffusion'
PatternDither 'PatternDither'

BRLMPrinterImageRotation

Members Value
Rotate0 'Rotate0'
Rotate90 'Rotate90'
Rotate180 'Rotate180'
Rotate270 'Rotate270'

BRLMPrinterVerticalAlignment

Members Value
Top 'Top'
Center 'Center'
Bottom 'Bottom'

BRLMPrinterHorizontalAlignment

Members Value
Left 'Left'
Center 'Center'
Right 'Right'

BRLMPrinterCompressMode

Members Value
None 'None'
Tiff 'Tiff'
Mode9 'Mode9'

BRLMPrinterPrintQuality

Members Value
Best 'Best'
Fast 'Fast'

BRLMPrinterCustomPaperType

Members Value
rollPaper 'rollPaper'
dieCutPaper 'dieCutPaper'
markRollPaper 'markRollPaper'

BRLMPrinterCustomPaperUnit

Members Value
mm 'mm'
inch 'inch'

BrotherPrintEventsEnum

Members Value
onPrinterAvailable 'onPrinterAvailable'
onPrint 'onPrint'
onPrintFailedCommunication 'onPrintFailedCommunication'
onPrintError 'onPrintError'

Prerelease channels

An open, non-draft pull request can be published to the npm beta dist-tag after its Validation and Package Candidate workflows pass. A repository owner or maintainer must add a comment whose entire body is:

/beta

The request authorizes only the pull request head SHA that existed when the comment was added. The workflow revalidates the owner or maintainer permission and head SHA immediately before publishing. Any new commit requires CI to pass again and a fresh owner or maintainer /beta comment. Fork pull requests are supported. Pull requests that change a release-gating workflow cannot be beta-published until those workflow changes land on main.

Beta versions use <base>-beta.pr<PR number>.sha<12-character SHA>. The candidate is built in a read-only workflow without npm publishing credentials. The privileged release workflow publishes only the validated immutable package artifact with lifecycle scripts disabled. A notification failure cannot invalidate a successful npm publish.

When a pull request is merged into main, it is automatically published to beta only after the required CI and Package Candidate succeed for that exact merge commit. Direct pushes to main do not publish a candidate.

Only npm run release creates a release tag. Stable vX.Y.Z tags publish to npm latest; revision/prerelease tags publish to next. Neither beta nor next publishing changes the npm latest dist-tag.

Maintainers

License

MIT

About

Capacitor plugin for Brother Print SDK

Resources

Contributing

Security policy

Stars

27 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages