Constants
Module escpos.constants
Set of ESC/POS Commands (Constants)
This module contains constants that are described in the Esc/Pos-documentation. Since there is no definitive and unified specification for all Esc/Pos-like printers the constants could later be moved to capabilities as in escpos-php by @mike42.
- author:
python-escpos developers
- organization:
Bashlinux and python-escpos
- copyright:
Copyright (c) 2012-2017 Bashlinux and python-escpos
- license:
MIT
- escpos.constants.CTL_LF: bytes = b'\n'
Print and line feed
- escpos.constants.CTL_FF: bytes = b'\x0c'
Form feed
- escpos.constants.CTL_CR: bytes = b'\r'
Carriage return
- escpos.constants.CTL_HT: bytes = b'\t'
Horizontal tab
- escpos.constants.CTL_SET_HT: bytes = b'\x1bD'
Set horizontal tab positions
- escpos.constants.CTL_VT: bytes = b'\x0b'
Vertical tab
- escpos.constants.CD_KICK_DEC_SEQUENCE(esc, p, m, t1=50, t2=50)
decimal cash drawer kick sequence
- escpos.constants.CD_KICK_2: bytes = b'\x1bp\x0022'
Sends a pulse to pin 2 []
- escpos.constants.CD_KICK_5: bytes = b'\x1bp\x0122'
Sends a pulse to pin 5 []
- escpos.constants.PAPER_FULL_CUT: bytes = b'\x1dV\x00'
Full cut paper
- escpos.constants.PAPER_PART_CUT: bytes = b'\x1dV\x01'
Partial cut paper
- escpos.constants.TXT_STYLE: ConstTxtStyleClass = {'align': {'center': b'\x1ba\x01', 'left': b'\x1ba\x00', 'right': b'\x1ba\x02'}, 'bold': {False: b'\x1bE\x00', True: b'\x1bE\x01'}, 'color': {'black': b'\x1br\x00', 'red': b'\x1br\x01'}, 'density': {0: b'\x1d|\x00', 1: b'\x1d|\x01', 2: b'\x1d|\x02', 3: b'\x1d|\x03', 4: b'\x1d|\x04', 5: b'\x1d|\x08', 6: b'\x1d|\x07', 7: b'\x1d|\x06', 8: b'\x1d|\x05'}, 'flip': {False: b'\x1b{\x00', True: b'\x1b{\x01'}, 'font': {'a': b'\x1bM\x00', 'b': b'\x1bM\x00'}, 'height': {1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7}, 'invert': {False: b'\x1dB\x00', True: b'\x1dB\x01'}, 'size': {'2h': b'\x1b!\x00\x1b!\x10', '2w': b'\x1b!\x00\x1b! ', '2x': b'\x1b!\x00\x1b!0', 'normal': b'\x1b!\x00\x1b!\x00'}, 'smooth': {False: b'\x1db\x00', True: b'\x1db\x01'}, 'underline': {0: b'\x1b-\x00', 1: b'\x1b-\x01', 2: b'\x1b-\x02'}, 'width': {1: 0, 2: 16, 3: 32, 4: 48, 5: 64, 6: 80, 7: 96, 8: 112}}
text style dictionary for
escpos.escpos.Escpos.set()
- escpos.constants.SET_FONT(n)
- escpos.constants.TXT_FONT_A: bytes = b'\x1bM\x00'
Font type A
- escpos.constants.TXT_FONT_B: bytes = b'\x1bM\x01'
Font type B
- escpos.constants.CODEPAGE_CHANGE: bytes = b'\x1bt'
Prefix to change the codepage. You need to attach a byte to indicate the codepage to use. We use escpos-printer-db as the data source.
- escpos.constants.BARCODE_TXT_OFF: bytes = b'\x1dH\x00'
HRI barcode chars OFF
- escpos.constants.BARCODE_TXT_ABV: bytes = b'\x1dH\x01'
HRI barcode chars above
- escpos.constants.BARCODE_TXT_BLW: bytes = b'\x1dH\x02'
HRI barcode chars below
- escpos.constants.BARCODE_TXT_BTH: bytes = b'\x1dH\x03'
HRI both above and below
- escpos.constants.BARCODE_FONT_A: bytes = b'\x1df\x00'
Font type A for HRI barcode chars
- escpos.constants.BARCODE_FONT_B: bytes = b'\x1df\x01'
Font type B for HRI barcode chars
- escpos.constants.BARCODE_HEIGHT: bytes = b'\x1dh'
Barcode Height [1-255]
- escpos.constants.BARCODE_WIDTH: bytes = b'\x1dw'
Barcode Width [2-6]
- escpos.constants.BARCODE_TYPE_A: Dict[str, bytes] = {'CODABAR': b'\x1dk\x06', 'CODE39': b'\x1dk\x04', 'EAN13': b'\x1dk\x02', 'EAN8': b'\x1dk\x03', 'ITF': b'\x1dk\x05', 'NW7': b'\x1dk\x06', 'UPC-A': b'\x1dk\x00', 'UPC-E': b'\x1dk\x01'}
Barcodes for printing function type A
- escpos.constants.BARCODE_TYPE_B: Dict[str, bytes] = {'CODABAR': b'\x1dkG', 'CODE128': b'\x1dkI', 'CODE39': b'\x1dkE', 'CODE93': b'\x1dkH', 'EAN13': b'\x1dkC', 'EAN8': b'\x1dkD', 'GS1 DATABAR EXPANDED': b'\x1dkN', 'GS1 DATABAR LIMITED': b'\x1dkM', 'GS1 DATABAR OMNIDIRECTIONAL': b'\x1dkK', 'GS1 DATABAR TRUNCATED': b'\x1dkL', 'GS1-128': b'\x1dkJ', 'ITF': b'\x1dkF', 'NW7': b'\x1dkG', 'UPC-A': b'\x1dkA', 'UPC-E': b'\x1dkB'}
Barcodes for printing function type B The first 8 are the same barcodes as type A
- escpos.constants.BARCODE_FORMATS = {'CODABAR': ([(1, 255)], '^[A-Da-d][0-9\\$\\+\\-\\.\\/\\:]+[A-Da-d]$'), 'CODE128': ([(2, 255)], '^\\{[A-C][\\x00-\\x7F]+$'), 'CODE39': ([(1, 255)], '^([0-9A-Z \\$\\%\\+\\-\\.\\/]+|\\*[0-9A-Z \\$\\%\\+\\-\\.\\/]+\\*)$'), 'CODE93': ([(1, 255)], '^[\\x00-\\x7F]+$'), 'EAN13': ([(12, 13)], '^[0-9]{12,13}$'), 'EAN8': ([(7, 8)], '^[0-9]{7,8}$'), 'GS1 DATABAR EXPANDED': ([(2, 255)], '^\\([0-9][A-Za-z0-9 \\!\\"\\%\\&\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\_\\{]+$'), 'GS1 DATABAR LIMITED': ([(13, 13)], '^[01][0-9]{12}$'), 'GS1 DATABAR OMNIDIRECTIONAL': ([(13, 13)], '^[0-9]{13}$'), 'GS1 DATABAR TRUNCATED': ([(13, 13)], '^[0-9]{13}$'), 'GS1-128': ([(2, 255)], '^\\{[A-C][\\x00-\\x7F]+$'), 'ITF': ([(2, 255)], '^([0-9]{2})+$'), 'NW7': ([(1, 255)], '^[A-Da-d][0-9\\$\\+\\-\\.\\/\\:]+[A-Da-d]$'), 'UPC-A': ([(11, 12)], '^[0-9]{11,12}$'), 'UPC-E': ([(7, 8), (11, 12)], '^([0-9]{7,8}|[0-9]{11,12})$')}
supported barcode formats