Skip to main content

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


Download files

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

Source Distribution

epos_print_xml-0.3.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

epos_print_xml-0.3-py3-none-any.whl (10.6 kB view hashes)

Uploaded Python 3

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