0
votes

I am new to the world of ESC/POS. I have an Epson TM-T20II printer USB connected to a Windows 7 desktop. The code below is a sample application obtained from Epson at this link: https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=269

For my test, I have pasted the code in Notepad and print its content to the Epson printer. The printer prints the code below "as is". What do I need to do in order to get the printer to interpret the ESC/POS commands?

ESC "@"
ESC "3" 18
ESC "a" 1
GS "!" 0x11
0xC9 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xBB LF
0xBA 0x20 0x20 0x20 0x45 0x50 0x53 0x4F 0x4E 0x20 0x20 0x20 0xBA LF
0xBA 0x20 0x20 0x20
GS "!" 0x00
"Thank you "
GS "!" 0x11
0x20 0x20 0x20 0xBA LF
0xC8 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xCD 0xBC LF
ESC "2"
GS "!" 0x00
ESC "J" 4
"NOVEMBER 1, 2012  10:30"
ESC "d" 3
ESC "a" 0
"TM-Uxxx                            6.75" LF
"TM-Hxxx                            6.00" LF
"PS-xxx                             1.70" LF LF
GS "!" 0x01
"TOTAL                             14.45" LF
GS "!" 0x00
"---------------------------------------" LF
"PAID                              50.00" LF
"CHANGE                            35.55" LF
ESC "p" 0 2 20
GS "V" 66 0
2
I just wanted to thank you for posting here on this subject. We are a small community of people who are beginners at ESC/POS & we really need discussion.Ibber Chochem

2 Answers

3
votes
  • First of all make sure that you are sending the escape character, not the letters ESC. The escape character looks like this ← (type alt+27).
  • Second (on PC) you need to send the file directly to the printer. One way to accomplish this is to use this tool called RawPrint. Good Luck!
2
votes

It seems that you just send the text with a printer driver to your printer. That is because your printer driver does not interpret the text that you enter but renders it for printing. You would instead have to send the raw byte sequences directly to your printer.

I don't know if there is a way to achieve this using only the Windows printer interface. Maybe there is something like a "raw"-driver. You could however use an ESC/POS-library. For php there is escpos-php and for Python there is python-escpos. There exist probably also libraries for other languages.

They supply you for example with abstraction of the ESC/POS command-set. This is an example for usage of python-escpos:

from escpos.printer import Usb

# the parameters of the next call depend on the
# Vendor ID and Product ID of your USB-printer
p = Usb(0x04b8,0x0202,0)
p.text("Hello World\n")
p.image("logo.gif")
p.barcode('1324354657687','EAN13',64,2,'','')
p.cut()

It connects to the printer, prints the text "Hello World" with a newline at the end. It then proceeds with printing an image (which has to be available of course) and a barcode and finally cuts the paper.

Moreover you could use p.raw(b'\x1b'+'@') to send the ESC/POS sequence "ESC @" to the printer. With this you could directly send your example to your printer.