Skip to main content

Support for Epson ESC/POS printer command system.

Project description

PyESCPOS

Development status Supported Python versions License Latest version

A Python support for Epson© ESC/POS® compatible printers.

Read more at Epson ESCPOS FAQ (PDF document).

This library is inspired on Manuel F. Martinez work for python-escpos implementation.

Tested Hardware

Current implementation was tested against following hardwares:

Manufacturer

Models

Firmware Versions

Urmet Daruma

DR700 L/H/M and DR700 L-e/H-e

02.51.00, 01.20.00, 01.21.00

Bematech S/A

MP-4200 TH

1.3, 1.6

Example Usage

Serial RS232 Example

Serial communications support requires PySerial version 2.7 or later.

from escpos.serial import SerialSettings
from escpos.impl.epson import GenericESCPOS

# assumes RTS/CTS for 'ttyS5' and infers an instance of RTSCTSConnection
conn = SerialSettings.as_from('/dev/ttyS5:9600,8,1,N').get_connection()
printer = GenericESCPOS(conn)
printer.init()
printer.text('Hello World!')

USB Example

USB support requires PyUSB.

# TODO: USB support example.

Bluetooth Example

Bluetooth support requires PyBlueZ (not yet implemented).

from escpos.bluetooth import BluetoothConnection
from escpos.impl.epson import GenericESCPOS

printer = GenericESCPOS(BluetoothConnection('01:0a:02:0b:03:0c'))
printer.init()
printer.text('Hello World!')

Printing Barcodes

There is a default set of parameters for printing barcodes. Each ESC/POS implementation will take care of the details and try their best to print your barcode as you asked.

from escpos import barcode
from escpos.serial import SerialSettings
from escpos.impl.epson import GenericESCPOS

conn = SerialSettings.as_from('COM1:9600:8:1:N').get_connection()
printer = GenericESCPOS(conn)
printer.init()
printer.code128('0123456789',
        barcode_height=96, # ~12mm (~1/2")
        barcode_width=barcode.BARCODE_DOUBLE_WIDTH,
        barcode_hri=barcode.BARCODE_HRI_BOTTOM)

printer.lf()

printer.ean13('4007817525074',
        barcode_height=120, # ~15mm (~9/16"),
        barcode_width=barcode.BARCODE_NORMAL_WIDTH,
        barcode_hri=barcode.BARCODE_HRI_TOP)

printer.cut()

The barcode data should be complete, that is, an EAN-13 barcode is formed from twelve digits plus check-digit. Most of the ESC/POS commands implementations requires only twelve digits and automaticaly calculate the check-digit. If you are dealing with, say, EAN-13 codes without the thirteenth-digit (the check-digit) just append zero (0) to the barcode class (or method) argument, so they can pass RE validation.

printer.ean13('4007817525074')  # is OK
printer.ean13('400781752507')   # raises ValueError
printer.ean13('4007817525070')  # is OK and prints 4007817525074 as expected

Disclaimer

It is important that you read this disclaimer.

None of the vendors or manufacturers cited in this entire project agree or endorse any of the patterns or implementations used. its names are used only where it makes sense and/or to maintain context.

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

PyESCPOS-0.0.5.tar.gz (20.4 kB view details)

Uploaded Source

File details

Details for the file PyESCPOS-0.0.5.tar.gz.

File metadata

  • Download URL: PyESCPOS-0.0.5.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyESCPOS-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a33cb15aab6485dc217bf3fd0b2988309637c69160dd3e40705ef5b5a111ddbc
MD5 cdb329c3e95f8f227eb78cb379f5d149
BLAKE2b-256 6172c80339d53d11efda3a65153b315c20a83637da5e05d9ed62acd7b63e8be7

See more details on using hashes here.

Supported by

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