Android Question Print ethernet

DonManfred

Expert
Licensed User
Longtime User
1. How is the Ethernetprinter connected to your Phone? Does your phone have a ETHERNET adapter?
2. Most probably the Manufacturer does provide a SDK. You need to use this SDK. Probably you need to write a wrapper for the SDK first (some java knowledge needed!).
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
All above replies from Experts are right, but in my case I complaining a lot of pain because each printer manufacturers has different sdk & approach! and it is painful to your app to support all world printers types. So take another way & avoid pain by the following:
  1. Create your print data as pdf from html script using this great lib
  2. Install any third parity printer service on client device, in wihch it will print your generated pdf doc on any printer: thermal, wifi, bluetooth or direct usb
  3. In my projects I used this printer service it cover all printers possibilities & types
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Hello @Simo_L_Uk

Personally I could do it with a POS Epson TMII printer which connects via ethernet to your LAN network (Not USB)

1620851953223.png
1620851999024.png

The smartphone must connect it via WIFI to the same LAN where the printer is connected.

The code in B4A that you must use is the following:

B4X:
Sub Process_Globals
    Dim TMT20II As Socket 'Network library
    Dim AStreams As AsyncStreams 'RandomAccessFile library
End Sub

Sub Activity_Create(FirstTime As Boolean)
    TMT20II.Initialize("TMT20II")
    TMT20II.Connect("192.168.0.100", 9100, 0) '100=Printer address, 9100=Port number (please look up port number)
End Sub

Sub TMT20II_Connected (Successful As Boolean)
    Log(Successful)
    If Successful Then
        AStreams.Initialize(TMT20II.InputStream, TMT20II.OutputStream, "AStreams")
        CallSub(Null, SendToPrinter)
    End If
End Sub

Sub SendToPrinter
    Dim SendMsg As String

    SendMsg = Chr(27) & Chr(61) & Chr(1) 'Select EPSON printer
    AStreams.Write(SendMsg.GetBytes("UTF8"))

    SendMsg = "Hello, this is a test print" 'Send this line to the EPSON printer
    AStreams.Write(SendMsg.GetBytes("UTF8"))

    SendMsg = Chr(27) & Chr(100) & Chr(2) 'Line feed
    AStreams.Write(SendMsg.GetBytes("UTF8"))

    SendMsg = Chr(27) & Chr(109) 'Partial cut receipt paper
    AStreams.Write(SendMsg.GetBytes("UTF8"))
End Sub

You confirm to me if it works well for you.
 
Upvote 0
Top