@simplymobile/capacitor-bixolon-sdk-printer
v8.0.1
Published
Capacitor Bixolon printer plugin (official Bixolon SDK)
Downloads
301
Readme
@simplymobile/capacitor-bixolon-sdk-printer
Capacitor plugin for Bixolon printers built on the official Bixolon Android SDK
(BixolonPrinter.jar). Android-only; on iOS and web every method is unimplemented.
Supports text printing (with per-line alignment / size / font), 1D bar codes, QR codes, bitmap
images, paper cut, printer status, reconnect/disconnect, and MSR (magnetic stripe reader) and
connection-state listeners emitted as Capacitor events (msrData, connectionChanged).
Install
npm install @simplymobile/capacitor-bixolon-sdk-printer
npx cap syncConstants
These numeric constants come from the underlying Bixolon SDK and are accepted by the corresponding options.
BarCodeSystem (BarCodeData.barcodeSystem)
| Name | Value |
| --------- | ----- |
| UPC_A | 65 |
| UPC_E | 66 |
| EAN13 | 67 |
| EAN8 | 68 |
| CODE39 | 69 |
| ITF | 70 |
| CODABAR | 71 |
| CODE93 | 72 |
| CODE128 | 73 |
BarCodeCharacterPosition (BarCodeData.characterPosition)
| Name | Value |
| -------------------------- | ----- |
| NOT_PRINTED | 0 |
| ABOVE_BAR_CODE | 1 |
| BELOW_BAR_CODE | 2 |
| ABOVE_AND_BELOW_BAR_CODE | 3 |
QRCodeModel (QRCodeData.model)
| Name | Value |
| --------- | ----- |
| MODEL_1 | 49 |
| MODEL_2 | 50 |
Image alignment (printBitmap alignment)
| Name | Value |
| -------- | ----- |
| ASIS | -11 |
| LEFT | -1 |
| CENTER | -2 |
| RIGHT | -3 |
TextDimension (TextLine.textWidth / textHeight)
Integer 0-7 (TD_0 … TD_7), where 0 is the smallest size.
CodePage (BixolonSettings.codePage)
Single-byte code-page index. Common values: 0 = CP_437_USA, 1 = CP_KATAKANA,
2 = CP_850_MULTILINGUAL, 16 = CP_1252_LATIN1 (default), 18 = CP_852_LATIN2,
19 = CP_858_EURO, 28 = CP_1251_CYRILLIC, 43 = CP_1250_CZECH. See the Bixolon SDK
documentation for the full list.
API
checkPermissions()requestPermissions()printText(...)printBarCode(...)printQRCode(...)printBitmap(...)cutPaper(...)getStatus(...)reconnect()disconnect()startMsrReaderListener()stopMsrReaderListener()startConnectionListener()stopConnectionListener()addListener('msrData', ...)addListener('connectionChanged', ...)removeAllListeners()- Interfaces
- Type Aliases
checkPermissions()
checkPermissions() => Promise<PermissionStatus>Check the current Bluetooth permission status.
Returns: Promise<PermissionStatus>
requestPermissions()
requestPermissions() => Promise<PermissionStatus>Request the Bluetooth permissions required to connect to printers.
Returns: Promise<PermissionStatus>
printText(...)
printText(options: { lines: TextLine[]; config?: BixolonSettings; }) => Promise<{ message: string; }>Print a list of text lines. Connects to the printer, prints, cuts the paper and disconnects.
| Param | Type |
| ------------- | -------------------------------------------------------------------------------------------- |
| options | { lines: TextLine[]; config?: BixolonSettings; } |
Returns: Promise<{ message: string; }>
printBarCode(...)
printBarCode(options: { data: BarCodeData; config?: BixolonSettings; }) => Promise<{ message: string; }>Print a 1D bar code.
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| options | { data: BarCodeData; config?: BixolonSettings; } |
Returns: Promise<{ message: string; }>
printQRCode(...)
printQRCode(options: { data: QRCodeData; config?: BixolonSettings; }) => Promise<{ message: string; }>Print a QR code.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------------------- |
| options | { data: QRCodeData; config?: BixolonSettings; } |
Returns: Promise<{ message: string; }>
printBitmap(...)
printBitmap(options: { base64Image: string; width?: number; brightness?: number; alignment?: number; }) => Promise<{ message: string; }>Print a Base64-encoded bitmap image.
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------------- |
| options | { base64Image: string; width?: number; brightness?: number; alignment?: number; } |
Returns: Promise<{ message: string; }>
cutPaper(...)
cutPaper(options?: { config?: BixolonSettings | undefined; } | undefined) => Promise<{ message: string; }>Feed/form-feed and cut the paper.
| Param | Type |
| ------------- | ------------------------------------------------------------------------- |
| options | { config?: BixolonSettings; } |
Returns: Promise<{ message: string; }>
getStatus(...)
getStatus(options?: { printStatus?: boolean | undefined; config?: BixolonSettings | undefined; } | undefined) => Promise<BixolonDeviceStatus>Return the connected printer status. When printStatus is true the status is also printed.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------ |
| options | { printStatus?: boolean; config?: BixolonSettings; } |
Returns: Promise<BixolonDeviceStatus>
reconnect()
reconnect() => Promise<{ message: string; }>Reconnect to the (first paired) printer.
Returns: Promise<{ message: string; }>
disconnect()
disconnect() => Promise<void>Disconnect from the currently connected printer.
startMsrReaderListener()
startMsrReaderListener() => Promise<void>Start listening for magnetic-stripe-reader (MSR) data. Emits msrData events.
stopMsrReaderListener()
stopMsrReaderListener() => Promise<void>Stop listening for MSR data.
startConnectionListener()
startConnectionListener() => Promise<void>Start listening for connection-state changes. Emits connectionChanged events.
stopConnectionListener()
stopConnectionListener() => Promise<void>Stop listening for connection-state changes.
addListener('msrData', ...)
addListener(eventName: 'msrData', listenerFunc: (data: MsrData) => void) => Promise<PluginListenerHandle>Listen for MSR (magnetic stripe reader) track data.
| Param | Type |
| ------------------ | -------------------------------------------------------------- |
| eventName | 'msrData' |
| listenerFunc | (data: MsrData) => void |
Returns: Promise<PluginListenerHandle>
addListener('connectionChanged', ...)
addListener(eventName: 'connectionChanged', listenerFunc: (data: ConnectionData) => void) => Promise<PluginListenerHandle>Listen for printer connection-state changes.
| Param | Type |
| ------------------ | ---------------------------------------------------------------------------- |
| eventName | 'connectionChanged' |
| listenerFunc | (data: ConnectionData) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Remove all registered listeners for this plugin.
Interfaces
PermissionStatus
| Prop | Type | Description |
| --------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| bluetooth | BluetoothPermissionState | Permission state for Bluetooth (BLUETOOTH_CONNECT / BLUETOOTH_SCAN on Android 12+). |
TextLine
A single line of text to print. Prefix text with [hr]<char> (e.g. "[hr]=") to draw a
horizontal rule filling the paper width.
| Prop | Type | Description |
| ---------------- | ----------------------------------------------- | -------------------------- |
| text | string | |
| textAlign | TextAlign | |
| textWidth | number | Horizontal text size, 0-7. |
| textHeight | number | Vertical text size, 0-7. |
| fontType | FontType | |
| fontStyle | FontStyle | |
BixolonSettings
Shared print configuration. All fields are optional; sensible defaults are applied natively
(lineFeed: 0, formFeed: true, autoConnect: true, toastMessage: true, codePage: 16).
| Prop | Type | Description |
| ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------- |
| lineFeed | number | Number of empty lines to feed after printing (used when formFeed is false). |
| formFeed | boolean | Whether to perform a form feed after printing instead of a line feed. |
| autoConnect | boolean | Android only. When true, connect to the first paired printer automatically; otherwise show a picker dialog. |
| toastMessage | boolean | Android only. Whether the underlying SDK is allowed to show toast messages. |
| codePage | number | Single-byte code page used for text printing. |
BarCodeData
| Prop | Type | Description |
| ----------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------- |
| text | string | |
| alignment | TextAlign | |
| width | number | |
| height | number | |
| barcodeSystem | number | Bar-code symbology (e.g. 73 for CODE128). See BarCodeSystem in the README. |
| characterPosition | number | Position of the human-readable characters (0 = none, 1 = above, 2 = below, 3 = both). |
QRCodeData
| Prop | Type | Description |
| --------------- | ----------------------------------------------- | ------------------------------------------ |
| text | string | |
| alignment | TextAlign | |
| size | number | QR module size, 1-8. |
| model | number | QR model (49 = model 1, 50 = model 2). |
BixolonDeviceStatus
| Prop | Type |
| --------------------- | ------------------- |
| printerName | string |
| printerAddress | string |
| cover | string |
| paper | string |
| battery | string |
| firmwareVersion | string |
| manufacturer | string |
| printerModel | string |
| codePage | string |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
MsrData
| Prop | Type |
| --------------- | ------------------- |
| msrTrack1 | string |
| msrTrack2 | string |
| msrTrack3 | string |
ConnectionData
| Prop | Type |
| ----------------- | --------------------------- |
| isConnected | boolean |
| message | string | null |
Type Aliases
BluetoothPermissionState
'granted' | 'denied' | 'prompt' | 'prompt-with-rationale'
TextAlign
'left' | 'center' | 'right'
FontType
'A' | 'B' | 'C'
FontStyle
'default' | 'bold' | 'underline' | 'underline2' | 'reversed'
