Skip to main content

Introduction

Complete set of documentation at https://pythonhosted.org/python-printer-escpos/

python-printer-escpos is a package to directly print to ESCPOS specification(http://content.epson.de/fileadmin/content/files/RSD/downloads/escpos.pdf) compliant POS printers directly over Serial, USB, Network or UNIX device file connections.

This package supports most of the escpos specification functionality and allows you to print QR codes, logo images, barcode in the default mode. The package may be extended by adding your own escpos.commandset.* module instead of the default escpos.commandset.generic package. If you extend the functionality for this package for a specific printer, do publish your code on PyPi and email to provide a link for your commandset in this package’s documentation.

Installation

Get some prerequisites first for image printing etc.

pip install Pillow

Install python-printer-escpos

pip install python-printer-escpos

Examples

USB Printer

Advanced Usage

See https://pythonhosted.org/python-printer-escpos/manual/connections/usb.hyml

Synopsis

from escpos.connections import getUSBPrinter


printer = getUSBPrinter()(idVendor=0x1504,
                          idProduct=0x0006
                          inputEndPoint=0x82,
                          outputEndPoint=0x01) # Create the printer object with the connection params

printer.text("Hello World")
printer.lf()

Network Printer

Advanced Usage

See https://pythonhosted.org/python-printer-escpos/manual/connections/network.html

Synposis

from escpos.connections import getNetworkPrinter


printer = getNetworkPrinter()(host='192.168.0.20', port=9100)

printer.text("Hello World")
printer.lf()

Serial Printer

Advanced Usage

See https://pythonhosted.org/python-printer-escpos/manual/connections/serial.html

Synposis

from escpos.connections import getSerialPrinter


printer = getSerialPrinter()(dev='/dev/ttyS0',
                          baudrate=9600)

printer.text("Hello World")
printer.lf()

Device File Printer

Advanced Usage

See https://pythonhosted.org/python-printer-escpos/manual/connections/file.html

Synposis

from escpos.connections import getFilePrinter


printer = getFilePrinter()(dev='/dev/ttys2')

printer.text("Hello World")
printer.lf()

Generic example code

See the full list of available default commands at https://pythonhosted.org/python-printer-escpos/modules/escpos.commandset.html

from escpos.connections import getUSBPrinter


printer = getUSBPrinter()(idVendor=0x1504,
                          idProduct=0x0006
                          inputEndPoint=0x82,
                          outputEndPoint=0x01) # Create the printer object with the connection params

# Print a image
printer.image('/home/shantanu/companylogo.gif')

printer.text("Hello World")
printer.lf()

printer.align('center')
printer.text('This text is center aligned')

# Print a barcode
printer.barcode(text='Shantanu', textPosition='below', font='b', height=100, width=2, system='CODE93')
printer.lf()

printer.bold()
printer.text('This text is bold text')
printer.lf()
printer.bold(False)
printer.text('This text is not bold')
printer.lf()

printer.charSpacing(1)
printer.text('This text has normal right char spacing')
printer.lf()
printer.charSpacing(5)
printer.text('This text has 5 right char spacing')
printer.lf()

printer.color()
printer.text('This text is in primary color')
printer.lf()
printer.color(1)
printer.text('This text is in color 1')
printer.lf()

printer.doubleHeight()
printer.text('This text is double height text')
printer.lf()
printer.doubleHeight(False)
printer.text('This text is not double height')
printer.lf()

printer.doubleStrike()
printer.text('This text is double strike text')
printer.lf()
printer.doubleStrike(False)
printer.text('This text is not double strike')
printer.lf()

printer.doubleWidth()
printer.text('This text is double width text')
printer.lf()
printer.doubleWidth(False)
printer.text('This text is not double width')
printer.lf()

printer.font('b')
printer.text('This text is in font b')
printer.lf()
printer.font('a')
printer.text('This text is in font a')
printer.lf()

printer.invert()
printer.text('This text is in inverted colors')
printer.lf()
printer.invert(False)
printer.text('This text is not in inverted colors')
printer.lf()

printer.leftMargin(30)
printer.text('This text has left Margin of 30')
printer.lf()

printer.lineSpacing()
printer.text('This text has 1/6 inch line spacing')
printer.lf()
printer.lineSpacing(5)
printer.text('This text has 5/60 inch line spacing')
printer.lf()

printer.printAreaWidth(200)
printer.text('Set print area width to 200')
printer.lf()
printer.text('1234567890123456789012345678901234567890123456789012345678901234567890')
printer.printAreaWidth()
printer.lf()

# Print QR Code
printer.qr('My name is Shantanu Bhadoria')
printer.qr('WIFI:T:WPA;S:ShantanusWifi;P:wifipasswordhere;;')  # Create a QR code for connecting to a Wifi
printer.lf()

printer.rotate90(100)
printer.text('This text is rotated 90 degrees')

printer.tabPositions([3, 32])
for plu in plus:
    printer.text(plu.quantity)
    printer.tab()
    printer.text(' x ' + plu.name)
    printer.tab()
    printer.text('$' + plu.price)

printer.underline()
printer.text('This text is underlined text')
printer.lf()
printer.underline(True,True)
printer.text('This text is double dot width underlined text')
printer.lf()
printer.underline(False)
printer.text('This text is not underlined')
printer.lf()

printer.upsideDown()
printer.text('This text is upside down')
printer.lf()
printer.upsideDown(False)
printer.text('This text is not upside down')
printer.lf()

printer.horizontalPosition(100)
printer.text('This text starts at 1/6inches from left margin')

printer.cutPaper()

printer.drawerKickPulse()

Release files for python-printer-escpos 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-printer-escpos 0.0.2
File Size Uploaded
python-printer-escpos-0.0.2.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-printer-escpos 0.0.2
File Interpreter ABI Platform
python_printer_escpos-0.0.2-py2-none-any.whl Python 2 none any Details

Total release size:26.6 kB

Release files / python-printer-escpos-0.0.2.tar.gz

Download URL python-printer-escpos-0.0.2.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3255f849a1632310c9bb5889af3ee551b8c55aa98ebddde455e608a2a3b71bb5
BLAKE2b-256 checksum
How to use checksums
3d4b5d301ec54ecddbfa36166b00aa2e9e4c899ee7c9bed6c84a0d9ada3285ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python_printer_escpos-0.0.2-py2-none-any.whl

Download URL python_printer_escpos-0.0.2-py2-none-any.whl
Size 14.4 kB
Tags Python 2
SHA-256 checksum
How to use checksums
19dfb12892cd55a973e4ea6a127816d17b9e3f0079e156bddbba768b078d60a7
BLAKE2b-256 checksum
How to use checksums
6fead37e531457682ada7b6e17935862fbb6fded6caf15d4b8401eb43dcd8c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.4

2 release files

0.0.3

1 release file

This release

0.0.2 This release

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page