escp
A Python library to drive ESC/P printers
Motivation
There is no driver available for your printer, or there is one but it is slow and the print quality is mediocre.
Missing driver can be worked around by using a generic 9-pin or 24-pin generic driver. To get the highest quality, this library focuses on text mode printing, leveraging device fonts (built-in fonts), as opposed to modern drivers that rely on graphics.
Installation
pip install escp
Use
Only USB is supported for now. You can find the id_vendor and id_product values using lsusb.
$ lsusb | grep -i epson
Bus 001 Device 004: ID 04b8:0005 Seiko Epson Corp. Printer
import escp
# Create a printer instance (Espon LX-300+II)
printer = escp.UsbPrinter(id_vendor=0x04b8, id_product=0x0005)
# Obtain commands for 9-pin printer
commands = escp.lookup_by_pins(9)
# Prepare the buffer to print a short text
commands.init().text('ESC/P direct printing test page').cr_lf(2)
# Printer go brrrrrr
printer.send(commands.buffer)
See demo for a more complete example.
Features
ESC/P, ESC/P2, ESC/POS
| Variant | Supported |
|---|---|
| ESC/P | ✓ |
| ESC/P2 | ✗ |
| ESC/POS | ✗ |
- ESC/P (Epson Standard Code for Printers), sometimes called Escape/P, is a printer control language developed by Epson to control computer printers. It was mainly used in dot matrix printers and some inkjet printers, and is still widely used in many receipt thermal printers. Supported. Primary target.
- ESC/P2 is a more recent variant of ESC/P by Epson. Backward compatible with ESC/P. Not supported. Switch to ESC/P but some features won't be available.
- ESC/POS is a variant for controlling receipt printers as commonly used at the point of sale (POS). Often thermal printers. Not supported and out of scope. Use the comprehensive python-escpos library instead.
References
Printers
Tested on a 9-pin reference printer: Epson LX-300+II. All 9-pin printers should work, with minor hardware limitations on some commands. 24/48-pin printers are implemented bt not tested. The differences between 9-pin and 24/48 pin are minor.
| Type | Status |
|---|---|
| 9-pin | Work in progress – Text mode |
| 24/48-pin | Work in progress – Text mode – Not tested |
Connectivity
| Connector | Status |
|---|---|
| USB | ✓ |
| Serial | ✗ |
| Parallel | ✗ |
| File | ✓ |
Although serial and parallel ports are not supported, you can output the printer commands to a file and send it in raw mode to the printer using lpr.
Credits
Inspired from python-escpos.
License
Metadata
Release files for escp 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| escp-0.0.6.tar.gz | 985.2 kB | Without provenance | Details for escp-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| escp-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for escp-0.0.6-py3-none-any.whl |
Total release size: 1.0 MB
Release files / escp-0.0.6.tar.gz
| Download URL | escp-0.0.6.tar.gz |
|---|---|
| Size | 985.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5a1bd4bd2e834287fc9718409b78635cf1bd53a6bfccef084f7b57fcff8b007
|
|
BLAKE2b-256 checksum How to use checksums |
2a2142b8136e009ae907a7bc1a0bc278e55412719dd17c7eb6fbd9c627c3ed3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / escp-0.0.6-py3-none-any.whl
| Download URL | escp-0.0.6-py3-none-any.whl |
|---|---|
| Size | 31.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d61b6e9933405cf06bf28b4b7f3eda36deb368c265b20d9f81a94cefc98357e
|
|
BLAKE2b-256 checksum How to use checksums |
c49c12d4a44e6d68c5e6bbc2c266d5798fd579f2c9477a045cfa1df9c05d4acd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for escp 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.