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.
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.
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).
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.
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.
open url in internal rawbt browser
Implemented a subset of the data URI scheme:
Documentation: Android Intents with Chrome
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.
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.
Remember that confidential information should not be placed on the permanent URL accessible without authorization.
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":
-------------------------------- TEST -------------------------------- 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.
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.
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: