I have a thermal printer that needs to be connected into my Android device via WiFi connection. I need it to be automatically print whenever a button is triggered (without the printing dialog)
Currently, I am using Ionic 4, but I cannot find any library which supports ESC/POS language. Any library that I could use?
Note: The following solution works for Ionic 4 and 5.
I managed to find the solution via TCP/IP port connection from ionic into my WiFi connected thermal printer
In order to create a TCP/IP socket connection from ionic, I used sockets for cordova and send byte into my thermal printer IP. Depending on each printer, each printer has different set of ESC command (CMIIW) which mean we still need to convert the byte code one by one and send them into the thermal printer.
Also, I have fork a repository https://www.npmjs.com/package/esc-pos-encoder-ionic which can be used as a wrapper to encode ESC command into byte code. Then the result can be sent into the printer using TCP/IP socket.
Hope this helps others too.
Demo source code: https://github.com/Ans0n-Ti0/esc-pos-encoder-ionic-demo