Quick Start

Last updated: November 5th, 2019

Hello, world!

To print the text to thermal printer connected to client's phone it is enough to place a special type of link on the site.

Simple example:

If you have a space “ “ in an URL, most probably it will not be recognize by the browser, all the special characters must be encoded (transformed).

Hello, world!

Scheme rawbt


At first glance, everything is well printed. But if you try to print a picture, we get an error. Urlencode is not binary safe. To solve this problem, I implemented the ability to transfer data in base64 encoding.

Useful Tip:

If you have not read the description of the functions of the program, do it now. You will understand better how the program processes the data you send to it.


The string that is encoded represents the GS v 0 control sequence.

Print picture


open url in internal rawbt browser

Base64 encode online


Implemented a subset of the data URI scheme:

  • 1. rawbt:data:image/jpeg;base64,data - print pictures immediately
    (jpeg, png and other formats that android understands)
  • 2. rawbt:data:application/pdf;base64,data
  • 3. rawbt:data:text/html;base64,data - open in browser
  • 4. rawbt:data:text/plain;base64,data - immediately to print plain UTF-8 text

Call using the Intent scheme

Documentation: Android Intents with Chrome

Intent scheme example:

Using the intent scheme is standard. An additional benefit from its use is that if the application is not installed, browser will automatically open app's page from the PlayMarket.

Hello, world!

Open with RawBT

After installing the application, it is registered in the system as a means to open http and http links that end with .txt, .prn or .pdf and also images (.png,.jpg,.bmp).

The method of printing through the placement of a simple file link is not reliable. The user can establish a permanent association of the extension with another application and the file will be opened in another application.

In order for the file to be received by my application, you need to use the intent scheme. But since the URL becomes long, it is easier to create it in a function, as shown below.

.txt .prn .pdf .png

Remember that confidential information should not be placed on the permanent URL accessible without authorization.

How to generate a receipt from javascript

The main task of the application is to implement a data delivery channel to the end device (printer) without distortion (This implements rawbt:base64,...).

When we create a page we usually use utf-8 encoding. The printer is awaiting data in single-byte encoding. The application simplifies the task of printing plain text in coding utf-8. (This is standart for rawbt)

Let's for example implement a printout of text from the pre block.

pre with id "pre_print":

Items 1
                      3 x $20.00
Items 2
                      1 x $40.00
                   TOTAL $100.00

As you can see, we just collect a string of text. For extended text formatting (for example: boldness, alignment), you must add escape sequences ( Wiki: ESC/P - printer control language ) to the string.

How print data generated by the back-end of the site

Ajax technology works well for this. More reliably, when encoding data in base64 is performed immediately on the server side.

I hope the young developers are familiar with jQuery, but experienced ones have not forgotten it.

Ajax example:

I offer a complete solution.

Download : RawBT server for PC

To print from a mobile phone on the Android operating system, my application is used, which does not require a license to easily transfer data from the site to the printer.

For printing from personal computers, you can use the following solution for free.

For popular libraries, data adapters in the desired format have been added:

  • Mike42/Escpos-php Available in library versions starting from 2.2 (php 5) and 3.0 (php 7)
  • song940/node-escpos (My pull request accepted to master branch #234) Available so far only in the dev version.


Use cases with paid solutions: