Few helpers, and they are free :)

Parameters:*constants (list) – constants to print.

Print a list of constants and their values.

>>> ls()
All constants will be printed here.

You can print only constants you want too:

>>> from thermalprinter.constants import Chinese, CodePage

>>> ls(Chinese)
Chinese values will be prited here.

>>> ls(Chinese, CodePage)
Chinese and CodePage values will be prited here.

Tests'/dev/ttyAMA0', heat_time=80)
  • port (str) – serial port to use, known as the device name.
  • heat_time (int) – printer heat time.

Send to the printer several insctructions to test every printing functions.

Code pages
Parameters:char (bytes) – bytes to print.

Test one character with all possible code page. Say you are looking for the good code page to print a sequence, you can print it using every code pages:

>>> test_char(b'现')

This function is as simple as:

for codepage in list(CodePage):
    printer.out('{}: {}'.format(, char),

Data validation

These are special functions to handle data validation. As it could take a lot of lines and logic, we prefered create them outsite the class to keep a light code for every ThermalPrinter’s methods.

thermalprinter.validate.validate_barcode(data, barcode_type) → None
  • data (mixed) – data to print.
  • barecode_type (BarCode) – bar code type to use.

Validate data against the bar code type.

thermalprinter.validate.validate_barcode_position(position) → None
Parameters:position (BarCodePosition) – the position to use.
Raises:ThermalPrinterConstantError – On bad position’s type.

Validate a bar code position.

thermalprinter.validate.validate_charset(charset) → None
Parameters:charset (CharSet) – new charset to use.
Raises:ThermalPrinterConstantError – On bad charset’s type.

Validate a charset.

thermalprinter.validate.validate_chinese_format(fmt) → None
Parameters:fmt (Chinese) – new format to use.
Raises:ThermalPrinterConstantError – On bad fmt’s type.

Validate a Chinese format.

thermalprinter.validate.validate_codepage(codepage) → None
Parameters:codepage (CodePage) – new code page to use.
Raises:ThermalPrinterConstantError – On bad codepage’s type.

Validate a code page.