Bluetooth Direct Printing
Bridges for connecting to Bluetooth thermal/receipt printers and sending raw ESC/POS or TSPL data directly - no WiFi required.
Android uses Bluetooth Classic (SPP - Serial Port Profile) via
BluetoothSocket, and BLE viaBluetoothGatt.iOS uses BLE (CoreBluetooth) exclusively via
AppleBluetoothPrint. Bluetooth Classic (SPP) is not available to third-party apps on iOS.
Android
Bridge object: AndroidBluetoothPrint
Methods
Method | Return | Description |
|---|---|---|
|
| Returns |
|
| Returns |
|
| Emits |
|
| Starts Bluetooth Classic + BLE discovery simultaneously; emits |
|
| Stops discovery |
|
| Connects via SPP or BLE to the given MAC address |
|
| Disconnects the current printer |
|
| Sends raw bytes (ESC/POS or TSPL) to the printer |
|
| Sends UTF-8 text with ESC/POS formatting; accepts a plain string or a JSON options object |
|
| Prints a text label using auto-generated TSPL commands |
|
| Sends a raw TSPL command string directly to the printer |
|
| Renders HTML as a monochrome bitmap and prints it via the TSPL |
|
| Returns |
|
| JSON string with device info, or |
|
| Returns BLE GATT services JSON (BLE connections only) |
|
| Prints a CPCL label using auto-generated CPCL commands |
|
| Sends a raw CPCL command string directly to the printer |
|
| Sends TSPL SELFTEST + TSPL/CPCL/ESC-POS test labels; emits |
Events
Event name |
| Description |
|---|---|---|
|
| List of paired devices |
|
| Discovery has started |
|
| A device was found |
|
| Discovery finished (BLE auto-stops after 12s) |
|
| Connected to printer |
|
| Disconnected from printer |
|
| Data sent successfully |
|
| An error occurred |
|
| Bluetooth permissions needed |
|
| Emitted for each step of |
mobiweb:btPrintSuccess type values:
Value | Triggered by |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Device Type Values
Value | Meaning |
|---|---|
| Unknown |
| Bluetooth Classic |
| BLE |
| Dual (Classic + BLE) |
printText(text | optionsJson)
Accepts either a plain string (legacy, prints as-is with one line feed) or a JSON options object:
Field | Type | Default | Description |
|---|---|---|---|
|
| - | (required) Text to print; use |
|
|
| Send |
|
|
|
|
|
|
| Bold text |
|
|
| Underline text |
|
|
|
|
|
|
| Blank lines to feed after text |
|
|
| Send partial paper cut after printing |
printTspl(optionsJson)
Generates and sends a complete TSPL label job. The bridge handles SIZE, GAP, CLS, TEXT, and PRINT automatically.
Field | Type | Default | Description |
|---|---|---|---|
|
| - | (required) Label text; use |
|
|
| Label width in mm |
|
|
| Label height in mm |
|
|
| Gap between labels in mm |
|
|
| Horizontal alignment: |
|
|
| Vertical alignment of text block: |
|
| (auto) | Explicit X position in dots; overrides |
|
| (auto) | Explicit Y position in dots; overrides |
|
|
| TSC built-in font name: |
|
|
| Scale multiplier applied on top of base font: |
|
|
| Number of copies to print |
TSC built-in fonts:
| Dimensions | Description |
|---|---|---|
| 8x12 dots | Small mono |
| 12x20 dots | Medium mono (default) |
| 16x24 dots | Large mono |
| 24x32 dots | Larger mono |
| 32x48 dots | Largest mono |
fontSize is a multiplier - e.g. font: "2" + fontSize: 2 = 24x40 dots per character.
printTsplRaw(tsplCommands)
Sends a raw TSPL command string directly to the printer with no modification. Use this for full TSPL control - barcodes, QR codes, images, and custom layouts.
Each command must be terminated with
\r\n.The bridge sends the string as UTF-8 bytes over SPP or BLE.
printCpcl(optionsJson)
Generates and sends a complete CPCL label job. CPCL (Comtec Printer Control Language) is used by Zebra, Intermec, Honeywell, and many portable label printers.
Field | Type | Default | Description |
|---|---|---|---|
|
| - | (required) Label text; use |
|
|
| Label height in dots |
|
|
| Printer DPI: |
|
|
| Number of copies |
|
|
| Left margin offset in dots |
|
|
| Text X position in dots |
|
|
| Starting text Y position in dots |
|
|
| Fixed font |
|
|
| Point size for scalable fonts; |
|
|
| Horizontal magnification |
|
|
| Vertical magnification |
|
|
|
|
CPCL fixed fonts (approx. dot heights at 200 DPI):
| Approx. height | Description |
|---|---|---|
| 18 dots | Smallest |
| 20 dots | Small |
| 24 dots | Medium |
| 30 dots | Medium-large |
| 40 dots | Large (default) |
| 48 dots | Larger |
| 56 dots | Even larger |
| 80 dots | Largest |
printCpclRaw(cpclCommands)
Sends a raw CPCL command string directly to the printer with no modification. Use for full CPCL control - barcodes, QR codes, images, boxes, and custom layouts.
The label must start with
! {offset} {hDpi} {vDpi} {heightDots} {qty}and end withPRINT\r\n.All commands must be uppercase; each line must be terminated with
\r\n.Add
PREFEED {n}\r\nafter the header line to feedndots forward before your content.Add
POSTFEED {n}\r\nbeforePRINT\r\nto feedndots forward after your content.
printHtml(optionsJson)
Renders an HTML string in a hidden WebView at the exact label dimensions, captures it as a monochrome bitmap, then sends it to the printer using the TSPL BITMAP command. Rendered at 203 DPI (8 dots/mm).
Field | Type | Default | Description |
|---|---|---|---|
|
| - | (required) HTML content to render |
|
|
| Label width in mm |
|
|
| Label height in mm |
|
|
| Gap between labels in mm |
|
|
| Number of copies |
|
|
| Grayscale threshold for black/white conversion (0-255; lower = more black) |
|
|
| Standard TSC TSPL spec uses |
|
|
| Print protocol: |
|
|
| Printer DPI: |
|
|
| Left margin offset in dots |
|
|
| Inserts |
|
|
| Inserts |
|
|
| CPCL bitmap encoding: |
getDeviceServices()
Returns a JSON string listing all discovered GATT services and characteristics for the currently connected BLE device. Only available when connected via BLE.
Return shape:
Returns { "error": "Not connected via BLE" } if not connected via BLE.
printDiagnostic()
Sends a sequence of test prints to verify the printer connection and determine which protocol the printer understands. Runs TSPL SELFTEST, a TSPL label, a CPCL label, and an ESC/POS text block in order.
Emits mobiweb:btDiagnostic after each step:
On failure, status will be "failed" and an "error" field is included. Check logcat for detailed output.
Full Connection Example
iOS
Bridge object: AppleBluetoothPrint (injected shim)
Methods
Method | Description |
|---|---|
| Checks Bluetooth state; emits |
| Starts BLE discovery; auto-stops after 12 s; emits |
| Stops BLE scan early |
| Connects to BLE peripheral by UUID; emits |
| Disconnects; emits |
| Sends raw bytes (base64-encoded, same as Android) |
| ESC/POS formatted text (same options as Android) |
| TSPL label printing (same options as Android) |
| Raw TSPL string (same as Android) |
| CPCL label printing (same options as Android) |
| Raw CPCL string (same as Android) |
| HTML-to-bitmap label printing (same options as Android + |
| Checks connection state; emits |
| Emits |
| Emits |
| Sends TSPL/CPCL/ESC-POS test prints; emits |
Events
Event name |
| Description |
|---|---|---|
|
| Result of |
|
| BLE scan has started |
|
| A BLE device was found ( |
|
| Scan complete |
|
| Connected |
|
| Disconnected |
|
| Result of |
| device info object | Result of |
|
| Result of |
|
| Data sent successfully |
|
| Diagnostic step result |
|
| An error occurred |
printHtml - iOS-only extra option
In addition to all the same options as Android, printHtml on iOS accepts one extra field:
Field | Type | Default | Description |
|---|---|---|---|
|
|
| Use zlib compression for TSPL |
Key Differences from Android
Feature | Android | iOS |
|---|---|---|
Transport | Classic (SPP) + BLE | BLE only |
| MAC address ( | BLE UUID ( |
| Returns | Emits |
| Returns | Emits |
| Returns JSON string | Emits |
| Returns JSON string | Emits |
| Supported | Not available (BLE has no classic pairing) |
TSPL bitmap compression | Not configurable |
|