Print with python on a POS printer with esc/pos
Define your printer¶(source: http://code.google.com/p/python-escpos/wiki/Usage)
Define your printer
Before start create your Python ESC/POS printer instance, you must see at your system for the printer parameters. This is done with the 'lsusb' command.
First run the command to look for the "Vendor ID" and "Product ID", then write down the values, these values are displayed just before the name of the device with the following format:
xxxx:xxxx
Example:
# lsusb
Bus 002 Device 001: ID 1a2b:1a2b Device name
Write down the the values in question, then issue the following command so you can get the "Interface" number and "End Point"
# lsusb -vvv -d xxxx:xxxx | grep iInterface
iInterface 0
# lsusb -vvv -d xxxx:xxxx | grep bEndpointAddress | grep OUT
bEndpointAddress 0x01 EP 1 OUT
The first command will yields the "Interface" number that must be handy to have and the second yields the "Output Endpoint" address.
By default the "Interface" number is "0" and the "Output Endpoint" address is "0x01", if you have other values then you can define with your instance.
Define your instance¶
The following example demonstrate how to initialize the Epson TM-TI88IV
from escpos import *
""" Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """
Epson = escpos.Escpos(0x04b8,0x0202,0)
# Print text
Epson.text("Hello World")
# Print image
Epson.image("logo.gif")
# Print barcode
Epson.barcode('1324354657687','EAN13',64,2,'','')
# Cut paper
Epson.cut()
