Android Question Print on Epson TM-T20II

Bladimir Silva Toro

Active Member
Licensed User
I wanted to ask if anyone could print on an Epson TM-T20II POS printer.

Is it easy to send printing from a mobile application in B4A?

Is there an example code?

I need to know if I can implement this solution to a client.

Thank you very much for your reply.
 

Bladimir Silva Toro

Active Member
Licensed User
Thank you f0raster0

I have already been able to print from a POS printer started with the smarthpone via Bluetooth

The Epson TM-T20II is a POS printer connected by USB to a PC with Windows Operating System.

It would be something like a LAN network printing from the Smartphone
 

DonManfred

Expert
Licensed User
Does the T20II support a Network-connection? I guess no.

I would like to suggest to use Epson SDK for this Printer (i remember there is one)

Edit to add: As the Printer is connected to the PC you need to PRINT on the PC. Run a B4J app on the pc which is able to get commands from a android device and print from the b4j app.
 

Bladimir Silva Toro

Active Member
Licensed User
@DonManfred

The Epson TM-T20II printer does not support direct connection to the Smartphone.

I have seen in the forum here: https://www.b4x.com/android/forum/threads/print-via-the-local-network.54432/

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
According to the code I see that it is possible to connect via network from the mobile device to the network printer, I want to know if that is possible.

I thank you very much for your help, since I don't want to promise my client something I can't do.
 
Top