Library to communicate with Epson thermal printers via ePOS-Print XML protocol
Project description
py-epos-print-xml
Python library to communicate with Epson thermal printers via ePos-Print XML. This makes it easy and intuitive to create print orders for ePos-Print XML compatible printers, like the Epson TM-T20, TM-m30 and TM-m50 series. Depending on the printer model, some elements are not supported. Check your manual or the Epson reference to see which elements are supported.
Instaling
pip install ePos-Print-XML
Example
from epos.printer import Printer
from epos.document import EposDocument
from epos.elements import Text, Feed, Barcode
from epos.constants import Align
# Create a new printer object with 10.0.0.12 as ip
printer = Printer('10.0.0.12')
# Check if we can connect to the printer with no errors, otherwise exit
if not printer.printer_ready():
exit()
# Create a new EposDocument object
# This will contain all the individual elements
doc = EposDocument()
# Add an element directly to the body of the document
doc.add_body(Text('This is example text!\n'))
doc.add_body(Feed()) # Another way to add a newline
# It's also possible to first create the text object and then change the properties
t = Text('Some special text :O\n')
t.bold = True
t.align = Align.CENTER
doc.add_body(t)
# Add 2 empty lines
doc.add_body(Feed(2))
# Add a barcode
doc.add_body(Barcode(BarcodeType.CODE39, 'text in barcode'))
# Send the whole document to the printer
# This will automatially send a Cut at the end of the document body
r = printer.print(doc)
# The print method returns a response element
# Here we can check if the printing was succesfull
if r.success:
print('The printing was successfull!')
else:
print(f'Printing failed. Error: {r.code}')
Documentation
Tech reference of all the xml elements by Epson: https://reference.epson-biz.com/modules/ref_epos_print_xml_en/index.php?content_id=1
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
File details
Details for the file epos_print_xml-0.3.tar.gz
.
File metadata
- Download URL: epos_print_xml-0.3.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3db55720ffdfb4e406ac91cac5e507e27327ffb32bf011594535580006d90e6 |
|
MD5 | 544668ba654c3149520da5997732e5b2 |
|
BLAKE2b-256 | 20a475f7738ace49d0d416454f848521498fcfcb242c4de1fab246c5c87e930c |
File details
Details for the file epos_print_xml-0.3-py3-none-any.whl
.
File metadata
- Download URL: epos_print_xml-0.3-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e78662df283769824d006e8e953fc894bde65c5254d62a88df78b62e0024ac8 |
|
MD5 | 01a37c9791647698c8021c456ca374a0 |
|
BLAKE2b-256 | a41e3463623ce4d90fb78e53f4bb085354fba7415a65cd3f6a8a65dfce7a70e0 |