ESC/POS receipt printing library in pure Python
Project description
escpos-python
A pure Python 3 library for printing ESC/POS receipts, barcodes, and QR codes directly via the operating system print spooler.
Works on macOS, Linux, and Windows using lp or print system commands.
🚀 Features
✅ ESC/POS command generation
✅ Text formatting (bold, underline, alignments, double width/height)
✅ Barcodes (EAN13, Code128, and more)
✅ QR codes (size, error correction)
✅ Cross-platform printing (no C extensions)
✅ Mock printer for testing
📦 Installation
pip install escpos-python
Or build from source using
flitortwine
🖨️ Usage Example
from escpos import (
POSPrinter,
POSReceiptBuilder,
POSTextBuilder,
POSPrintStyle,
POSTextAlignment,
POSBarcodeBuilder,
POSBarcodeType,
POSQRCodeBuilder,
POSQRCodeSize,
POSQRCodeErrorCorrection
)
printer = POSPrinter("Your_Printer_Name")
receipt = (
POSReceiptBuilder()
.set_title("ESC/POS PYTHON DEMO")
.add_component(POSTextBuilder("Left").set_alignment(POSTextAlignment.LEFT).build())
.add_component(POSTextBuilder("Center").set_alignment(POSTextAlignment.CENTER).build())
.add_component(POSTextBuilder("Right").set_alignment(POSTextAlignment.RIGHT).build())
.add_component(POSTextBuilder("Bold").set_style(POSPrintStyle.BOLD).build())
.add_component(POSTextBuilder("Underlined").set_style(POSPrintStyle.UNDERLINE).build())
.add_item("Item A", 3.5)
.add_item("Item B", 5.0)
.add_component(
POSBarcodeBuilder("123456789012")
.set_type(POSBarcodeType.JAN13_EAN13)
.build()
)
.add_component(
POSQRCodeBuilder("https://example.com")
.set_size(POSQRCodeSize.LARGE)
.set_error_correction(POSQRCodeErrorCorrection.HIGH)
.build()
)
.set_footer("Thank you!")
.build()
)
printer.print(receipt)
🖨️ How to Find Printer Names
macOS / Linux
lpstat -p
Windows (PowerShell)
Get-Printer | Select Name
🧪 Testing with a Mock Printer
from escpos import POSPrinterMock, POSReceiptBuilder, POSTextBuilder
mock = POSPrinterMock()
receipt = (
POSReceiptBuilder()
.set_title("Test Receipt")
.add_component(POSTextBuilder("Line 1").build())
.build()
)
mock.print(receipt)
print("Printed buffers:", len(mock.get_printed_data()))
📣 Feature Request?
This repository is only for bug reports and maintenance related to the language-specific implementation.
Please open all feature requests, enhancements, and cross-language discussions in the central repository:
📜 License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file escpos_python-1.0.2.tar.gz.
File metadata
- Download URL: escpos_python-1.0.2.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a1b3ca11d57e6cba0d3ce4828fc9a6a01cbb094294486d0c9b52e6ab3dc4f04
|
|
| MD5 |
de585f557c6594a428352210d4d72860
|
|
| BLAKE2b-256 |
8beffcacb28a363af2cc84d6b22053da2d7ed49b06d3afa8c2aee834e5079898
|
Provenance
The following attestation bundles were made for escpos_python-1.0.2.tar.gz:
Publisher:
python-publish.yml on DrBackmischung/ESCPOS-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
escpos_python-1.0.2.tar.gz -
Subject digest:
7a1b3ca11d57e6cba0d3ce4828fc9a6a01cbb094294486d0c9b52e6ab3dc4f04 - Sigstore transparency entry: 195869245
- Sigstore integration time:
-
Permalink:
DrBackmischung/ESCPOS-Python@10e25bab2a0d5c98886a1484bcd03b4693dd82b5 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/DrBackmischung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@10e25bab2a0d5c98886a1484bcd03b4693dd82b5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file escpos_python-1.0.2-py3-none-any.whl.
File metadata
- Download URL: escpos_python-1.0.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c27f30637c4044211934c7cb75b785911096cd910181210942483c9ffda854b6
|
|
| MD5 |
dad6703c89a4a50447422ac27e2131dc
|
|
| BLAKE2b-256 |
65007e8718af60972fe44aa2341943682da388c368caa1d24d07a54de98085cb
|
Provenance
The following attestation bundles were made for escpos_python-1.0.2-py3-none-any.whl:
Publisher:
python-publish.yml on DrBackmischung/ESCPOS-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
escpos_python-1.0.2-py3-none-any.whl -
Subject digest:
c27f30637c4044211934c7cb75b785911096cd910181210942483c9ffda854b6 - Sigstore transparency entry: 195869248
- Sigstore integration time:
-
Permalink:
DrBackmischung/ESCPOS-Python@10e25bab2a0d5c98886a1484bcd03b4693dd82b5 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/DrBackmischung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@10e25bab2a0d5c98886a1484bcd03b4693dd82b5 -
Trigger Event:
release
-
Statement type: