Capabilities

Module escpos.capabilities

Handler for capabilities data.

exception escpos.capabilities.NotSupported[source]

Bases: Exception

Raised if a requested feature is not supported by the printer profile.

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class escpos.capabilities.BaseProfile[source]

Bases: object

This represents a printer profile.

A printer profile knows about the number of columns, supported features, colors and more.

profile_data: Dict[str, Any] = {}
get_font(font)[source]

Return the escpos index for font.

Makes sure that the requested font is valid.

Return type:

int

get_columns(font)[source]

Return the number of columns for the given font.

Return type:

int

supports(feature)[source]

Return true/false for the given feature.

Return type:

bool

get_code_pages()[source]

Return the support code pages as a {name: index} dict.

Return type:

Dict[str, int]

escpos.capabilities.get_profile(name=None, **kwargs)[source]

Get a profile by name.

If no name is given, return the default profile.

escpos.capabilities.get_profile_class(name)[source]

Load a profile class.

For the given profile name, load the data from the external database, then generate dynamically a class.

Return type:

Type[BaseProfile]

escpos.capabilities.clean(s)[source]

Clean profile name.

Return type:

str

escpos.capabilities.ProfileBaseClass

alias of DefaultProfile

class escpos.capabilities.Profile(columns=None, features=None)[source]

Bases: DefaultProfile

Profile class for user usage.

For users, who want to provide their own profile.

get_code_pages()

Return the support code pages as a {name: index} dict.

Return type:

Dict[str, int]

get_font(font)

Return the escpos index for font.

Makes sure that the requested font is valid.

Return type:

int

profile_data: Dict[str, Any] = {'codePages': {'0': 'CP437', '1': 'CP932', '11': 'CP851', '12': 'CP853', '13': 'CP857', '14': 'CP737', '15': 'ISO_8859-7', '16': 'CP1252', '17': 'CP866', '18': 'CP852', '19': 'CP858', '2': 'CP850', '20': 'Unknown', '21': 'CP874', '22': 'Unknown', '23': 'Unknown', '24': 'Unknown', '25': 'Unknown', '254': 'Unknown', '255': 'Unknown', '26': 'Unknown', '3': 'CP860', '30': 'TCVN-3-1', '31': 'TCVN-3-2', '32': 'CP720', '33': 'CP775', '34': 'CP855', '35': 'CP861', '36': 'CP862', '37': 'CP864', '38': 'CP869', '39': 'ISO_8859-2', '4': 'CP863', '40': 'ISO_8859-15', '41': 'CP1098', '42': 'CP774', '43': 'CP772', '44': 'CP1125', '45': 'CP1250', '46': 'CP1251', '47': 'CP1253', '48': 'CP1254', '49': 'CP1255', '5': 'CP865', '50': 'CP1256', '51': 'CP1257', '52': 'CP1258', '53': 'RK1048', '6': 'Unknown', '66': 'Unknown', '67': 'Unknown', '68': 'Unknown', '69': 'Unknown', '7': 'Unknown', '70': 'Unknown', '71': 'Unknown', '72': 'Unknown', '73': 'Unknown', '74': 'Unknown', '75': 'Unknown', '8': 'Unknown', '82': 'Unknown'}, 'colors': {'0': 'black'}, 'features': {'barcodeA': True, 'barcodeB': True, 'bitImageColumn': True, 'bitImageRaster': True, 'graphics': True, 'highDensity': True, 'paperFullCut': True, 'paperPartCut': True, 'pdf417Code': True, 'pulseBel': False, 'pulseStandard': True, 'qrCode': True, 'starCommands': False}, 'fonts': {'0': {'columns': 42, 'name': 'Font A'}, '1': {'columns': 56, 'name': 'Font B'}}, 'media': {'dpi': 'Unknown', 'width': {'mm': 'Unknown', 'pixels': 'Unknown'}}, 'name': 'Default', 'notes': 'Default ESC/POS profile, suitable for standards-compliant or Epson-branded printers. This profile allows the use of standard ESC/POS features, and can encode a variety of code pages.\n', 'vendor': 'Generic'}
supports(feature)

Return true/false for the given feature.

Return type:

bool

get_columns(font)[source]

Get column count of printer.

Return type:

int