B4A Library SD EscPos Printer (Lan,USB, Bluetooth SPP, BLE)

George_G

Member
Licensed User
As has already been answered in the other section of the forum, you have to set the Code Page for Greek (one of these 7,65,66,67,68) but mainly the printer must support the code page.

You have to do the tests
In my case, the best solution is to create a bitmap, and print it.
 

lkching7

Member
Licensed User
Longtime User
Can connect to the virtual Bluetooth printer ?
The virtual Bluetooth printer is without MAC Address. The only way is connect by UUID
 

Star-Dust

Expert
Licensed User
Longtime User
Thank
 

Olli73

Member
Licensed User
Longtime User
I try to use this it with "EPSON TM-m30III", connected by lan
The sample work for me.... sometimes.....
If I disconnect the connection (connected by lan) by checking the radiobutton "Disconnect All", and if I want to connect again, I get Lan_Connected = false everytime. I have to restart the activity.
Is it because of the limitations in Demo Libraries?

And how can I change the Charset? I need a Charset for printing "ö, ä, ü ....". But L_Printer.SetCodePage(6) dont work for me... the printed letter changed, but it is not an "Ö"....
 

Star-Dust

Expert
Licensed User
Longtime User
If you use disconnect to reopen the channels you must reinitialize the class.

For CharSet use CodeTable and SetCodePage
 

Olli73

Member
Licensed User
Longtime User
Hello! I have problems with the timing of sending to my Epson printer - connected by lan. If I stop manually by a breakpoint, it is printing. Without breakpoint, it is not printing.... I think, I dont understand the timing of the printer? I need to make a pause? Without, sometimes the printer print only parts of the lines.... Is "sleeping" the right way to do it?

B4X:
If LanConnected Then
       
        Dim n As Nachricht = myNachricht
       
        L_Printer.CenterJustify
        L_Printer.Writeline(ESC_POS.DoubleOn & "TICKET" & ESC_POS.DoubleOff)
        L_Printer.WriteLine(ESC_POS.feed(2))
        L_Printer.LeftJustify
        Sleep(500)
        Dim byteList As List = TextToWPC1252(n.Textnachricht) 'Encode a string to WPC1252 Byte Array'
       
        For Each bstr() As Byte In byteList '!!! If make a breakpoint in Debug - it is printing - without breakpoint it is not printing'
            L_Printer.Write_ArrayByte(bstr)
            L_Printer.Write(CRLF)
            Sleep(100)
        Next
       
        L_Printer.WriteLine(ESC_POS.feed(2))
        byteList = TextToWPC1252(n.Absender)
        For Each bstr() As Byte In byteList
            L_Printer.Write_ArrayByte(bstr)
            L_Printer.Write(CRLF)
        Next
        L_Printer.WriteLine(n.Datum)
        L_Printer.WriteLine(ESC_POS.feed(2))
        L_Printer.WriteLine(ESC_POS.feed(2))
        L_Printer.WriteLine(ESC_POS.CutPartialPaper)
       
        Sleep(200)
           
    End If
 

Star-Dust

Expert
Licensed User
Longtime User
I can't quite understand what you're describing.
But you seem to say that if you go into debug and stop it prints but in release mode the printer seems to be waiting for data.

This can happen if the streaming system waits for more data before sending, perhaps thinking it can fill the cache. Usually you should force the flush.
But to make a maneuver like this you have to be sure that this is the problem.

for further explanations see this link
 

Star-Dust

Expert
Licensed User
Longtime User
NEW
Starting from SDK33 runtime permissions are required for accessing Bluetooth, see this link
 

Pablo Torres

Active Member
Licensed User
Longtime User
Hi,

Something like this is happening to me everytime.
I have 2 printers in my b4A project, one USB connected and one LAN, the USB works ok but the LAN only prints once.
I send a notification for LAN printer, notification works OK but The printer seems like disconnect.
I also tried Printer.Connect(Host,Port) before printing and Printer.Disconnect after printing... but only prints first time
Can anyone help me?
The relevant code is the next: (L_Printer is the lan printer and I setup a timer for printing)
B4X:
Sub tmrComanda_Tick
    TimerComanda.Enabled=False
    Log("INTENTANDO CONECTAR")
    If L_Printer.IsInitialized Then
        L_Printer.Connect(strIP,9100)
        Wait For LAN_Connected(Success As Boolean)
        If Success Then
            Try
                L_Printer.CenterJustify
                L_Printer.WriteLine(ESC_POS.BoldOn & ESC_POS.DoubleOn & strEncabezado)
                L_Printer.Writeline(ESC_POS.BoldOn & ESC_POS.DoubleOn & strOrdenComanda)
                L_Printer.LeftJustify
                L_Printer.Write(ESC_POS.BoldOff & ESC_POS.DoubleOff & strImpresion)
                L_Printer.WriteLine(ESC_POS.CutPaper)
                L_Printer.WriteLine(ESC_POS.DoubleOn & " ")
                L_Printer.Beep(4,2)
                Sleep(1000)
                L_Printer.Disconnect
            Catch
                Log("ERROR AL IMPRIMIR COMANDA")
                Log(LastException)
            End Try
        Else
            Log("NO CONECTÓ IMPRESORA")
            Sleep(2000)
            TimerComanda.Enabled=True
        End If
    Else
        Log("INICIANDO IMPRESORA")
        L_Printer.Initialize(Me,"LAN")
        TimerComanda.Enabled=True
    End If
End Sub

Here are the logs:
[log]
INTENTANDO CONECTAR
INTENTANDO CONECTAR
NO CONECTÓ IMPRESORA
INTENTANDO CONECTAR
NO CONECTÓ IMPRESORA
INTENTANDO CONECTAR
NO CONECTÓ IMPRESORA[/log]

It looks like after disconnect it is not able to connect again... what should I do?
I tried many many things, but havent reach to a solution

Any help will be highly appreciated


Many Thanks
 

Star-Dust

Expert
Licensed User
Longtime User
some printers (few) seem to freeze.
You can try either to keep a connection always active for the next prints, or after printing send the reset command. see if you can solve it with these methods
 

Pablo Torres

Active Member
Licensed User
Longtime User
some printers (few) seem to freeze.
You can try either to keep a connection always active for the next prints, or after printing send the reset command. see if you can solve it with these methods
Thank you my friend for your help.
How do I keep the connection active?
Reset command? I also dont know how to do that

Any tip on those 2 advices will be very good for me

Many thanks again
 

Star-Dust

Expert
Licensed User
Longtime User
Reset

B4X:
Printer.InitializePrinter
 

Star-Dust

Expert
Licensed User
Longtime User
to keep it active you should initialize the class when the app opens and disconnect when it closes. this works if the printer drops the connection in the meantime.
 

Star-Dust

Expert
Licensed User
Longtime User
unfortunately I think it is something related to the printer. or the printer remains pending waiting for some information because you sent a wrong command
 

Star-Dust

Expert
Licensed User
Longtime User
1.09
  • Disconnect method now flushes before closing
 

Lakhtin_V

Active Member
Licensed User
Longtime User
In my case I am testing Xprinter XP-420B, with this example and the last library I have come very close to success. According to the logs, the text and picture embedded inside the example go to the printer without errors, but nothing is printed. The printer is silent and does not twitch. But a message appears: this is a Demo library, I'm sorry
 

Star-Dust

Expert
Licensed User
Longtime User
Hi, the demo version has some limitations. It prints every two minutes. (See post #1) When you see that message, it means that the feature is limited.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…