Skip to main content

Python library to manipulate ESC/POS Printers

Project description

ESCPOS
======

Python library to manipulate ESC/POS Printers.

1. Dependencies
---------------

In order to start getting access to your printer, you must ensure
you have previously installed the following python modules:

* pyusb (python-usb)
* PIL (Python Image Library)

2. Description
--------------

Python ESC/POS is a library which lets the user have access to all
those printers handled by ESC/POS commands, as defined by Epson,
from a Python application.

The standard usage is send raw text to the printer, but in also
helps the user to enhance the experience with those printers by
facilitating the bar code printing in many different standards,
as well as manipulating images so they can be printed as brand
logo or any other usage images migh have.

Text can be aligned/justified and fonts can be changed by size,
type and weight.

Also, this module handles some hardware functionalities like, cut
paper, carrier return, printer reset and others concerned to the
carriage alignment.

3. 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:
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
lsusb -vvv -d xxxx:xxxx | grep bEndpointAddress | grep 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 "0x82", if you have other values then you can define
with your instance.


4. Define your instance
-----------------------

The following example shows how to initialize the Epson TM-TI88IV
*** NOTE: Always finish the sequence with Epson.cut() otherwise you will endup with weird chars being printed.

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()

or use with statement:

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 cut paper

5. Links
--------

Please visit project homepage at:
http://repo.bashlinux.com/projects/escpos.html

* Manuel F Martinez <manpaz@bashlinux.com>
* Dmitry Orlov <me@mosquito.su>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-escpos-1.0.7.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file python-escpos-1.0.7.tar.gz.

File metadata

File hashes

Hashes for python-escpos-1.0.7.tar.gz
Algorithm Hash digest
SHA256 96c3a90ea0c504f85deb10b59a40198a38ad2fd48b9b2b9584ef1e98986854df
MD5 9fb5cce5bc1f1c55b776f7749db4fb25
BLAKE2b-256 bf1db15ad9dbce20b4a244350d9c6ddbce2e1ccd408ef821ad8b72a6edc28a7f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page