Skip to main content

escpos_gen

Description

Generator of printable binary files with helper methods based on ESC/POS protocol.

Methods to:

  • Create tables providing data and table format.
  • Set text format in ESC/POS protocol.
  • Open drawer.
  • Ring buzzer.
  • Print text.
  • Predefined horizontal lines.
  • Get ESC/POS commands to print images.
  • Generate ESC/POS printable binary file.

Supports spanish characters.

Instalation

Run the following to install:

pip install escpos_gen

Usage

from escpos_gen import escGenerator
a = escGenerator()

options = {
    "columns":[
        {
            "text": "Cant",
            "type": "data",
            "header_align": "center",
            "data_align": "left"
        },
        {
            "text": "Descripción",
            "type": "fill",
            "header_align": "center",
            "data_align": "left",
            "data_fill_car": " "
        },
        {
            "text": "Precio",
            "type": "data",
            "header_align": "center",
            "data_align": "right"
        }
    ],
    "show_headers": True,
    "show_data": True,
    "border_top" : False,
    "border_right" : False,
    "border_bottom" : True,
    "border_left" : False,
    "separate_header": True,
    "separate_cols": True,
    "separate_rows": False,
    "row_separator_style": "blank-dashed",
    "style": "blank-line",
    "table_align": "center"
}
data = [
    ["1", "Hamburguesa con papas y mucho aguacate porfavor", "$50.00"],
    ["1", "Cocacola ", "$10.00"],
    ["1", "Sprite", "$10.00"],
    ["2", "Tacos barbacoa", "$24.00"],
    ["1", "Torta ahogada", "$23.00"],
    ["2", "Torta ahogada", "$23.00"],
    ["3", "Torta ahogada", "$23.00"],
    ["4", "Torta ahogada", "$23.00"]
]


a.table(data, options)
data_to_print = a.generate()

str_dev_printer = f"/dev/usb/lp2"
dev_printer = open(str_dev_printer, 'wb')
dev_printer.write(data_to_print)

Release files for escpos-gen 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 escpos-gen 0.0.2
File Size Uploaded
escpos_gen-0.0.2.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for escpos-gen 0.0.2
File Interpreter ABI Platform
escpos_gen-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size:11.7 kB

Release files / escpos_gen-0.0.2.tar.gz

Download URL escpos_gen-0.0.2.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
84aa2084da2c9fb5d9ebeea62b365230507146462a085aec95cb4b038bf19030
BLAKE2b-256 checksum
How to use checksums
abc1d4b34fa7274c1ffe9b1988836d4b1e09eecd3c9e40db74e51bcb757dde22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / escpos_gen-0.0.2-py3-none-any.whl

Download URL escpos_gen-0.0.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4250b82a54795addb2558ec0bc631450b9c47fc47405dc5afa49df706ad187b
BLAKE2b-256 checksum
How to use checksums
a200c7da94404465bbb3d8210961568fbadc027feebd1c5b059db2cede87d785
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

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