Star-Dust

Expert
Licensed User
Longtime User
I don't have an ESC / POS lan printer and therefore can't make it.
 
Last edited:

jahswant

Well-Known Member
Licensed User
Longtime User
I don't have an ESC / POS lan printer and therefore can't make it.
Just a push . This is the code I use to print for lan ESC / POS printers.

B4X:
Dim LANPRINTER As Socket 'Network library
Dim AStreams As AsyncStreams 'RandomAccessFile library

LANPRINTER.Initialize("LANPRINTER")
LANPRINTER.Connect(PIp, Pport, 0) '100=Printer address, 9100=Port number (please look up port number)


Sub LANPRINTER_Connected (Successful As Boolean)
        If Successful Then
            AStreams.Initialize(LANPRINTER.InputStream, LANPRINTER.OutputStream, "AStreams")
            AStreams.Write(PrintTicket1(Sales_Code1).GetBytes("UTF8"))
            Sleep(2000)
            AStreams.Close
            TMT20II.Close
        End If
End Sub

Sub AStreams_NewData (Buffer() As Byte)
    Dim msg As String
    msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
    LogDebug("AStreams_NewData = " & msg)
End Sub

Sub AStreams_Error
    BCT.Show(LastException.Message)
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Thanks @jahswant, you were very kind.
I have already done the library for Zebra LAN, BLE and USB without having a Zebra printer. But it was actually a gentle way to say no to my friend @Xfood. ? ? ? ? ?

Now you have taken away the excuse for not carrying it out
 

Star-Dust

Expert
Licensed User
Longtime User
Good morning Maicon,

The library also works correctly on B4XPage. If you can't see the printers you are wrong in the manifest and / or in the permission request.
Make sure you know the latest changes required to use Bluetooth on SDK 30. (here)

Here you see the version of the example for B4xPages.



PS
In the example you sent me privately there are several errors. As I have already written to you, make sure you know how to set the manifest and how to request permissions inside a B4XPage.
 

Star-Dust

Expert
Licensed User
Longtime User
ANNOUNCEMENT

Starting today, this library will be abandoned and will no longer be distributed.
After 5 years from the moment it was developed, I can say that it has run its full course and now there is a need to take a leap forward.

A new, more comprehensive Android library for ESC / POS thermal printers will be released. (here)
Unlike iOS id which only allows LAN and BLE connection with o.s. Android can be connected in 5 different ways (BT, BLE, LAN, USB, NFC) and I want to collect it in one library.

Here is a preview of the prototype I am testing

 
Last edited:

Lakhtin_V

Active Member
Licensed User
Longtime User
Hello, I tried your example for working with a Bluetooth printer. But I only managed to find the printer. Printing does not work. I checked this printer and my smartphone with other applications, everything is OK. I have a Xpinter XP-420B printer for printing labels. I was surprised that in this example does not have a label size setting. Can you help me set up your program to work with Xpinter XP-420B. For example, in the "print label" app, the label size is configured, but the data transfer protocol is not configured. When I use the "print label" app on the same test smartphone, everything prints out fine. Maybe someone can tell me what to pay attention to, I myself am a beginner in solving printing problems on a Bluetooth printer.
 

Star-Dust

Expert
Licensed User
Longtime User
Sorry, this library will be abandoned and will no longer be distributed.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…