Connecting to a printer

804 views
Skip to first unread message

PedroD

unread,
Oct 3, 2015, 8:54:38 PM10/3/15
to AndroidScript
Hi,
A couple of years ago I created a tablet based epos. It has a lamp server and browser based client. The receipt printer is connected to the server as getting printing to work from a tablet browser is difficult.

Now as Droidscript can talk over otg or Bluetooth, I am thinking about the possibility of rewriting my epos to run on top of Sqlite and buying a Bluetooth receipt printer.

Anybody out there ever tried this?

Pete

Dave Smart

unread,
Oct 5, 2015, 6:19:22 AM10/5/15
to AndroidScript
Hi Pete,

One of our users (Fernando Remor) is successfully printing to Chinese thermal label printers via Bluetooth serial, so I guess it should be possible.

Also, in the latest private beta, we have added the web.Print() method to webview which prints docs on Kitkat or greater using the in-built Android printing services.... so if you find a printer that supports that, then life might be easier :)

(Let me know if you want to go on the private beta list)

Regards
David

Fernando Remor

unread,
Oct 5, 2015, 8:32:21 AM10/5/15
to AndroidScript
Hi. It,s simple.

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );
    btn = app.CreateButton( "ok");
    btn.SetOnTouch(Print);
    lay.AddChild( btn );
    bt = app.CreateBluetoothSerial();
    bt.SetOnConnect(bt_OnConnect);
    bt.SetOnReceive(bt_OnReceive);
    bt.SetSplitMode("End","\n");
    //bt.SetSplitMode("Size",2);
    app.ShowPopup("Conectando MPT-II!","Bottom,Short");
    bt.Connect("MPT-II",0);
    app.AddLayout( lay );
}

function bt_OnConnect(ok){
    if(ok){app.ShowPopup("Impressora Conectada","Bottom,Short");}
    else{app.ShowPopup("Falha ao Conect Impressora!","Bottom,Short");}
    }
function bt_OnReceive(data){app.ShowPopup(data);}
function Print(){
    bt.Write('********************************\n');
    bt.Write('Test for Printer \n');
    bt.Write('================================\n');
    bt.Write('Its OK\n');
    bt.Write('\n\n\n\n');
}

I make a system for config printer on webview an send for ds. Printer Name and Printer Port.

Fernando Remor

unread,
Oct 5, 2015, 1:01:38 PM10/5/15
to AndroidScript
Yes it is easy, but the impression is text only. Not Print in graphic mode. The solution would be to use ESC / POS command, but bt.write (string), ESC / POS commands can not be sent.
I will test whether web.print () communicates with bluetooth printer, to communicate, just format in an iframe and send to the printer.

Steve Garman

unread,
Oct 28, 2015, 6:06:58 PM10/28/15
to AndroidScript
Fernando, can you not send escape sequences using the hex write mode?

See Dave's post https://groups.google.com/d/msg/androidscript/bwT2uYr9mic/rDURqQyUAAAJ

Peter Diffey

unread,
Oct 30, 2015, 5:25:51 PM10/30/15
to AndroidScript
Here is the code I used with my el cheapo BT printer.

    bt.Write("\x1D\x68\x28\n");
    bt.Write("\x1D\x77\x02\n");
    bt.Write("\x1D\x48\x02\n");
    bt.Write("\x1D\x66\x00\n");
    //ean13 barcode with digits underneath
    bt.Write("\x1D\x6B\x025012335113404\x00\n\n\n\n");

The first 4 lines are preamble to set the barcode size, the lines could be combined, the \n's are unnecessary.

At the end of the 4th line is a hex \x00. JavaScript interprets 00 as an end of text signal, so it must be the end of a write command, as the rest of the command will be ignored.

Pete

sami sghaier

unread,
Sep 26, 2017, 8:31:31 AM9/26/17
to DroidScript
I have a chinese printer with android SDK , can you please help me with finding the right commands to send to the printer?
thank you in advance.

Dave Smart

unread,
Sep 27, 2017, 10:39:04 PM9/27/17
to DroidScript
What type of printer is it?  

Where is the SDK?

tenagak...@gmail.com

unread,
Aug 24, 2018, 10:38:38 AM8/24/18
to DroidScript
hello,
i am using printer too, how to set the font size?

sometimes i need to print out header text woth bold and bigger, then print the other text with normal font size.

thanks for any help.

Maurizio R.

unread,
Jan 9, 2021, 3:17:23 PM1/9/21
to DroidScript
Serial BlueTooth. I have to print on 3 serial printers via Bluetooth, sequentially send the print on the first indicating its address, then the second and finally the third. If anyone has already had experience on this job I would be happy to use it. thanks and good to go
Message has been deleted

Maurizio R.

unread,
Jan 9, 2021, 3:33:51 PM1/9/21
to DroidScript

about the printing on thermal printer of barcodes or images I forward you android sdk of a typical thermal printer and a plugin  esc-pos encoder  that I created following the instructions of DAVE, but I have not yet managed to obtain a good result.

in allegato trovate plugin blackstack plugin encode for converting data HEX , and  sdk bluetooth android for example script send image serial bluetooth on the printer
bacstack.zip
Message has been deleted

Maurizio R.

unread,
Jan 9, 2021, 3:39:39 PM1/9/21
to DroidScript
sdk thermal printer serial bluetooth android example

src.zip
Reply all
Reply to author
Forward
0 new messages