I am developing a web-based POS. Unfortunately, POS must print through a thermal receipt printer (TM-T88IV, Epson). The web application is based on Django. Is there any idea on
Two options here: print an html page or provide a PDF file.
Note: it was not clear initially that prints should be automatic, which means the answer is not directly useful to OP.
Show the receipt as an html page, then create a media="print"
CSS stylesheet which the browser will use when printing the receipt. There's a lot to say about CSS print style sheets, but what's important is that you should remove all navigation elements and images that are going to be expensive to print.
When you do this, the user will simply have to print the page himself. You can also add a "Print Me" button which is going to show your user a printer dialog. This is done via JavaScript:
Print this page
(This is a bit obstrusive for your clients who don't have JS, check this tutorial about JS printing for a better way.)
Generate a PDF in Django, and show it to the user. He will be free to print it or save it on his computer later. Most web sites do this since it's far easier to control the layout of a PDF file, and it will be easier to make it look like a real receipt.