How to use Epson POS printer TM-T20II under linux

Getting an epson pos printer up and running under linux is very easy:

# add current user to lp group (requires relogin to work properly)
sudo usermod -a -G lp $USER

# for TM-T20II add udev rule (optional in my case):
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0e15", MODE="0664", GROUP="lp"' > sudo tee -a /etc/udev/rules.d/99-escpos.rules
sudo service udev restart

# install pip and pipenv
sudo apt install python-pip
pip install --user pipenv

# install download python-escpos and submodules
git clone https://github.com/python-escpos/python-escpos.git
cd python-escpo
git submodule update --init --recursive

# install including deps
pipenv install -e .

Now you should be ready to use the installation. From your installation repository run a pipenv shell by using “pipenv shell” or simply run “pipenv run python _your-script_.py” to run a script directly.

Here is an example script:

from escpos.printer import Usb

# see https://github.com/python-escpos/python-escpos/blob/development/src/escpos/escpos.py

""" Seiko Epson Corp. Receipt Printer (EPSON TM-T20II) """
p = Usb(0x04b8, 0x0e15, 0, profile="TM-T88II")

p.set(bold=True, underline=1, align='center', custom_size=True, width=2, height=2)
p.textln("Hello world")
p.ln(count=1)
p.set()
p.textln("this is a test")

p.set(align='center')
p.image("examples/graphics/climacons/rain.png")
p.qr("Dies ist ein Test", size=8)
p.set()

p.barcode('1324354657687', 'EAN13', width=3)
p.barcode('123456', 'CODE39', width=3)

p.block_text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", font='a', columns=None)

p.cut()