Blog

Thermal Printing From Ionic, Cordova and Capacitor Apps (Without Bluetooth Plugins)

28 October 2026 · 5 min read · By the Raw Print team

The most reliable way to print receipts from an Ionic, Cordova or Capacitor app on Android is not to talk to the printer yourself. Build the receipt as ESC/POS bytes in JavaScript, then open a rawbt:base64,… link with Capacitor's App Launcher or Cordova's _system target. Android hands the link to a print service app (RawBT or Raw Print), which owns the Bluetooth or USB connection and prints instantly. Your app stays free of fragile native Bluetooth code.

The approach in four lines:

  1. Encode the receipt with @point-of-sale/receipt-printer-encoder.
  2. Base64-encode the bytes.
  3. Open rawbt:base64,<data> as an external URL.
  4. The print service app prints it on the paired printer.

Option 1: Bluetooth plugins (and why they hurt)

You can add a Bluetooth serial or BLE plugin and write ESC/POS bytes to the printer yourself. Many projects start there. Most regret it, because your app then owns every hard problem:

  • Permissions change with Android versions. Android 12 replaced location-based Bluetooth permissions with BLUETOOTH_SCAN and BLUETOOTH_CONNECT. Older community plugins request the wrong ones and silently find nothing.
  • Bluetooth Classic vs BLE. Most cheap receipt printers use Bluetooth Classic (SPP). Popular, maintained plugins focus on BLE. Classic serial plugins are often unmaintained.
  • Connection management. You need reconnection, timeouts, one job at a time, and chunked writes so budget printers don't drop data.
  • Printer quirks. Paper width, code pages, image commands and print speed all vary between models.
  • Background printing. If your app isn't in front, Android may kill the connection.

That's a printing engine's worth of work inside a hybrid app.

Option 2: Hand the job to a print service app

Android print service apps already solve all of the above. RawBT popularised a simple contract: open a URL with the rawbt: scheme, and the app prints its contents. Raw Print accepts the same links, so the same code works with either app, and the user can choose the app they prefer.

LinkWhat prints
rawbt:base64,<b64>Raw ESC/POS bytes, sent to the printer untouched
rawbt: + encodeURIComponent(text)Plain text
rawbt:data:image/png;base64,<b64>A picture
rawbt:data:application/pdf;base64,<b64>A PDF
rawbt:https://…A file or web page downloaded and printed (Raw Print)

Raw Print also registers its own rawprint: scheme with the same forms.

Step 1: Build the ESC/POS bytes

// npm install @point-of-sale/receipt-printer-encoder
import ReceiptPrinterEncoder from '@point-of-sale/receipt-printer-encoder';

export function buildReceipt(order) {
  const enc = new ReceiptPrinterEncoder({ language: 'esc-pos', columns: 32 });
  enc.initialize().codepage('auto')
     .align('center').bold(true).line(order.shop).bold(false)
     .align('left');
  for (const item of order.items) {
    const left = `${item.qty} x ${item.name}`;
    const right = item.total.toFixed(2);
    enc.line(left.slice(0, 32 - right.length - 1).padEnd(32 - right.length) + right);
  }
  return enc.newline().align('center').qrcode(order.url)
            .newline(3).cut('partial').encode();
}

export function toBase64(bytes) {
  let bin = '';
  for (let i = 0; i < bytes.length; i += 0x8000) {
    bin += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
  }
  return btoa(bin);
}

Set columns to 48 for 80 mm printers. More encoder options in ESC/POS in JavaScript and Node.js.

Step 2a: Open the link from Capacitor

Use the official App Launcher plugin. It starts an Android "view" intent for the URL, which Android routes to the print app:

// npm install @capacitor/app-launcher && npx cap sync
import { AppLauncher } from '@capacitor/app-launcher';
import { buildReceipt, toBase64 } from './receipt';

export async function printOrder(order) {
  const url = 'rawbt:base64,' + toBase64(buildReceipt(order));
  const { completed } = await AppLauncher.openUrl({ url });
  if (!completed) {
    // No app handles rawbt: links. Ask the user to install a print app.
  }
}

Step 2b: Open the link from Cordova

With cordova-plugin-inappbrowser, the _system target hands the URL to Android instead of opening it inside the app:

const url = 'rawbt:base64,' + toBase64(buildReceipt(order));
cordova.InAppBrowser.open(url, '_system');

In a plain Ionic web build running in Chrome on Android (a PWA or a hosted web POS), window.location.href = url is enough.

Step 3: Set up the printer once

The print app keeps the printer connection, so setup happens once per device:

  1. Install the print app and pair the printer in it.
  2. Print a test from the app.
  3. Print from your app. If Android asks which app should open the link, choose the print app and tap Always.

With Raw Print, setup is three taps (scan, tap the printer, print a test), it keeps the printer connected in the background, and it can cut the paper and open the cash drawer after each job if the user turns those options on.

Tips from production

  • Keep links reasonably small. Android passes the URL inside an intent, and intents have a size limit (around a megabyte, shared with other data). Text receipts are tiny; a full-width photo can be large. For big images, print a rawbt:https://… link to a file your server hosts, or shrink the image first.
  • Use plain rawbt: links, not intent://…;package=…. An intent URL that names a package only opens that one app, so users can't switch print apps and you can't fall back.
  • Encode text in the app, not the printer. If you send raw ESC/POS, your encoder picks the code page. If you'd rather not deal with code pages (Arabic, Hindi, Thai), send plain text or HTML and let the print app render it as an image.
  • Detect a missing print app. Capacitor's openUrl returns completed: false when nothing handles the link. Show an install prompt.
  • Native Android code? You can skip links entirely and send an explicit intent. Raw Print accepts com.zaheelabs.rawprint.action.PRINT with the bytes as a BASE64 extra, plus text, HTML, URL and file variants.

What about RawBT's source code?

People search for "RawBT source code" hoping to embed its printing logic in their own app. RawBT's app source isn't published. If you want open code, look at:

  • Open ESC/POS Print Service (GPL-3.0): a complete open-source Android print service.
  • ESCPOS-ThermalPrinter-Android by DantSu (MIT): a library for printing from your own native Android app over Bluetooth, TCP or USB.
  • The JavaScript encoders above, which handle the ESC/POS side in your web code.

Compare more options in the best ESC/POS libraries on GitHub. Users looking for app setup help can read our RawBT guide.

Frequently asked questions

How do I print to a Bluetooth thermal printer from Ionic?

Either use a native Bluetooth plugin and send ESC/POS bytes yourself, or build the bytes in JavaScript and open a rawbt:base64, link so a print service app prints them. The second approach avoids Bluetooth permission and connection problems.

Does this work on iOS?

No. rawbt: print apps are Android-only. On iOS you need the printer maker's SDK or a BLE plugin, and a printer that supports BLE or Apple's MFi program.

Why does window.location.href with rawbt: do nothing in my Capacitor app?

The WebView may treat the link as in-app navigation. Open it through @capacitor/app-launcher so Android receives it as an external intent.

Can I check whether the printer is connected before printing?

Not through a link, which is one-way. The print app shows connection problems to the user on the device. If you need status in your app, use a native plugin or the printer's network status.