1

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.

Cheezey
  • 500
  • 5
  • 15

1 Answers1

6

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

Cheezey
  • 500
  • 5
  • 15
  • Great job with esc-post-encoder-ionic! Could you share the code example of how you integrated sockets for cordova in your Ionic project? – Ing. Alejandro Villalón Sep 21 '19 at 20:16
  • Unfortunately I do not have the code anymore (that was my previous freelance project) but I have requested my friend to extract the file. Please check it out at https://github.com/randy161/Ionic-4-Socket-EscPos-Printer-Sample/blob/master/Sample/printer.service.ts If you need more info, I can hel – Cheezey Sep 22 '19 at 15:04
  • I thank you very much for the link, it has helped me. Your esc-post-encoder-ionic package also helped me a lot, I will try to make an ionic version for sockets-for-cordova. If I stuck, can I ask you for help? so we can publish it. – Ing. Alejandro Villalón Sep 23 '19 at 21:00
  • Yup, Sure. Glad that it helped :) – Cheezey Sep 24 '19 at 04:33
  • Hey @Cheezey I'm currently interested in this. but the github link is broken. Do you have any repository related to this. Really hard to find information about thermal printers with Ionic... – Gonzalo Oct 08 '20 at 11:20
  • 1
    Hello @Gonzalo I have created a demo ionic application. Check it out https://github.com/Ans0n-Ti0/esc-pos-encoder-ionic-demo – Cheezey Oct 10 '20 at 05:45
  • @cheezey do you have demo versions of Bluetooth plugin..thanks – Glen Oct 29 '20 at 02:17
  • 1
    I recently developed printing via Bluetooth connection into 80mm thermal printer. Will update the demo repo soon. – Cheezey Oct 29 '20 at 07:19
  • @Cheezey thanks a lot...waiting fr that also i have asked bounty question ..Pls anwser if possible https://stackoverflow.com/questions/64552320/android-app-with-bluetooth-pos-printer-with-in-ionic-framework – Glen Oct 30 '20 at 06:04
  • Hello, sure. Sorry for the slight delay due to holiday, I can't really test it out. Maybe what I can do is upload the latest ionic demo with Bluetooth functionality so that you can try it :) – Cheezey Oct 30 '20 at 08:16