https://github.com/mosquito/python-escpos
用python实现控制小票机打印。
from escpos import * """ Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """ Epson = escpos.Escpos(0x04b8,0x0202,0) Epson.text("Hello World") Epson.image("logo.gif") Epson.barcode Epson.barcode('1324354657687','EAN13',64,2,'','') Epson.cut()
with EscposIO(printer.Network('192.168.1.87', port=9100)) as p: p.set(font='a', codepage='cp1251', size='normal', align='center', bold=True) p.printer.set(align='center') p.printer.image('logo.gif') p.writelines('Big line\n', font='b') p.writelines(u'Привет', color=2) p.writelines(u'BIG TEXT', size='2x') # After exit of with, printer will cut the paper