Android Question BT-PRINTER (BLUETOOTH) VERSION 0.15 STAR-DUST

manuelsalazar

Member
Licensed User
Hi, I have been using your library, and sometimes prints perfect the things that I put in the buffer and sometime does not print with the same android machine (its random issue) , routine, and printer , is there anything that I am doing wrong ?????
 

Star-Dust

Expert
Licensed User
Hi, I have been using your library, and sometimes prints perfect the things that I put in the buffer and sometime does not print with the same android machine (its random issue) , routine, and printer , is there anything that I am doing wrong ?????
Sometimes if the buffer has been overfilled (for example with large images or more images) the bluetooth is not able to transmit correctly.

So it could be the case to send the buffer in print immediately after each image
 

Star-Dust

Expert
Licensed User
Each image SendBufferToPrinter
 

manuelsalazar

Member
Licensed User
I use the following code ........

B4X:
Sub Printer_ConnectedToPrint (Success As Boolean)
    Dim borrado As String
'    When is connect
    If Success Then
        Printer.ClearBuffer
        Printer.AddBuffer_WriteLine(Main.RComercio)
        Printer.AddBuffer_WriteLine(Main.RTienda)
        Printer.AddBuffer_WriteLine(Main.RUbica)
        Printer.SendBufferToPrinter
        Printer.ClearBuffer
        Printer.AddBuffer_WriteLine(" ")
        Printer.AddBuffer_WriteLine(RFecha)
        Printer.SendBufferToPrinter
        Printer.ClearBuffer
        Printer.AddBuffer_BarCode(Right("000000"&NumberFormat(FOLIOPEDIDO,0,0),7))
        Printer.SendBufferToPrinter
        Printer.ClearBuffer
        Printer.AddBuffer_WriteLine("NOTA : "&Right("000000"&NumberFormat(FOLIOPEDIDO,0,0),7))
        Printer.AddBuffer_WriteLine("TOTAL  :  $ "&NumberFormat2(ptotal, 0, 2, 2, True))
        Printer.SendBufferToPrinter
        Printer.ClearBuffer
        Printer.AddBuffer_WriteLine(" ")
        Printer.AddBuffer_WriteLine(" ")
        Printer.SendBufferToPrinter
        Printer.ClearBuffer
        Printer.Close
    end if

the problem is that the last two Printer.AddBuffer_WriteLine(" "), doesn´t print space lines (like feed) , I don´t know whats wrong!!!!!
 

Star-Dust

Expert
Licensed User
Printer.ClearBuffer not necessary, but you could put sleep (200) to allow the printer buffer to receive and execute commands.

B4X:
 If Success Then
        Printer.ClearBuffer
        Printer.AddBuffer_WriteLine(Main.RComercio)
        Printer.AddBuffer_WriteLine(Main.RTienda)
        Printer.AddBuffer_WriteLine(Main.RUbica)
        Printer.SendBufferToPrinter
        Printer.AddBuffer_WriteLine(" ")
        Printer.AddBuffer_WriteLine(RFecha)
        Printer.SendBufferToPrinter
        Printer.AddBuffer_BarCode(Right("000000"&NumberFormat(FOLIOPEDIDO,0,0),7))
        Printer.SendBufferToPrinter
        Sleep(100)
        Printer.AddBuffer_WriteLine("NOTA : "&Right("000000"&NumberFormat(FOLIOPEDIDO,0,0),7))
        Printer.AddBuffer_WriteLine("TOTAL  :  $ "&NumberFormat2(ptotal, 0, 2, 2, True))
        Printer.SendBufferToPrinter
        Sleep(100)
        Printer.AddBuffer_WriteLine(" ")
        Printer.AddBuffer_WriteLine(" ")
        Printer.FlushAndClose
      
    end if
It could be the ClearBuffer that eliminates the print before it is sent, while it is still in the queue
 

manuelsalazar

Member
Licensed User
Hi :

when I use Printer.FlushAndClose , and I want to print another ticket, the program sends me that CANNOT CONNECT TO BT PRINTER.

Also sometimes with writeline center the text into the line , and sometime to the left of the line.


is there anything I can do about it ????

thanks in advanced ...
 

Star-Dust

Expert
Licensed User
it is strange, however it uses SendBufferToPrint, Sleep (500) and Close
 

manuelsalazar

Member
Licensed User
Hi :

How can I use the BluetoothIsDisabled event, for checking the status , because if it`s OFF when the program tries to connect to printer sends error java.io.IOException?

also , is there any field in ESC_POS that change to small font instead of the normal (standard) font ?


thanks in advanced.
 

Star-Dust

Expert
Licensed User
Hi :

How can I use the BluetoothIsDisabled event, for checking the status , because if it`s OFF when the program tries to connect to printer sends error java.io.IOException?
No, you cannot use to check the status.

This event is raised by checking a BluetoothAdmin type variable. If the BluetoothAdmin.IsEnabled variable has the value true, but the bluetooth is disabled it elevates this event.

But sometimes other exceptions are needed, which generate runtime errors. Make sure you have the necessary permissions to turn on the bluetooth

also , is there any field in ESC_POS that change to small font instead of the normal (standard) font ?


thanks in advanced.
There are many ESC_POS commands, I have included only a few, of which I was sure they were compatible on all models.

But you can add new ones
B4X:
Dim SampleNewCommand as String = Chr (27) & "!" & Chr (8)
 
Top