Module escpos
LUA library for printing to ESC/POS-compatible thermal printers.
Info:
- Copyright: 2024
- License: MIT
- Author: Sodomon sodomon2@gmail.com, Máster Vitronic mastervitronic@gmail.com
Functions
| connector_type (types) | Define the connector for devices |
| two_columns (col1, col2) | Aligns two columns from 2 strings. |
| three_columns (col1, col2, col3) | Aligns three columns from 3 strings. |
| set_line_spacing (height) | Defines the space between lines. |
| selectPrintMode (mode) | Defines the type of print mode. |
| set_color (color) | Defines the color to use (only if the printer supports color). |
| set_text_size (widthMultiplier, heightMultiplier) | Define the text size. |
| setBarcodeHeight (height) | Defines the height of the barcode. |
| setBarcodeWidth (width) | Defines the width of the barcode. |
| setBarcodeTextPosition (position) | Defines the position of the barcode content. |
| barcode (_type, str) | Creation of the barcode. |
| setEmphasis (on) | Defines whether Emphasis will be activated. |
| setJustification (justification) | Define the type of justification to use. |
| setFont (font) | Define what type of font to use. |
| feed (nl) | Send a feed. |
| text (text) | Send a text with line break. |
| print_qrcode (content, err_co, size, model) | Print the given data as a QR code on the printer. |
| cut (mode, lines) | Cut the paper. |
Functions
- connector_type (types)
-
Define the connector for devices
Parameters:
- types linux or network
See also:
Usage:
escpos:connector_type("linux")
- two_columns (col1, col2)
-
Aligns two columns from 2 strings.
Parameters:
Usage:
escpos:two_columns("TITLE", "SUBTITLE")
- three_columns (col1, col2, col3)
-
Aligns three columns from 3 strings.
Parameters:
Usage:
escpos:three_columns("TITLE", "SUBTITLE", "COMMENT")
- set_line_spacing (height)
-
Defines the space between lines.
Parameters:
- height integer
Usage:
escpos:set_line_spacing(4)
- selectPrintMode (mode)
-
Defines the type of print mode.
Parameters:
- mode
modes available for use:
escpos.MODE_FONT_A escpos.MODE_FONT_B escpos.MODE_EMPHASIZED escpos.MODE_DOUBLE_HEIGHT escpos.MODE_DOUBLE_WIDTH escpos.MODE_UNDERLINE
Usage:
escpos:selectPrintMode(escpos.MODE_UNDERLINE) - mode
- set_color (color)
-
Defines the color to use (only if the printer supports color).
Parameters:
- color
Valid colors:
escpos.COLOR_1 escpos.COLOR_2
Usage:
escpos:set_color(escpos.COLOR_2) - color
- set_text_size (widthMultiplier, heightMultiplier)
-
Define the text size.
Parameters:
- widthMultiplier integer
- heightMultiplier integer
Usage:
escpos:set_text_size(3, 3)
- setBarcodeHeight (height)
-
Defines the height of the barcode.
Parameters:
- height integer
Usage:
escpos:setBarcodeHeight(4)
- setBarcodeWidth (width)
-
Defines the width of the barcode.
Parameters:
- width integer
Usage:
escpos:setBarcodeWidth(7)
- setBarcodeTextPosition (position)
-
Defines the position of the barcode content.
Parameters:
- position
avaliable position:
escpos.BARCODE_TEXT_NONE (does not show the text) escpos.BARCODE_TEXT_ABOVE (shows text at the top of the page) escpos.BARCODE_TEXT_BELOW (displays text at the bottom)
Usage:
escpos:setBarcodeTextPosition(escpos.BARCODE_TEXT_BELOW) - position
- barcode (_type, str)
-
Creation of the barcode.
Parameters:
- _type types of barcodes: upca, upce, jan13, jan8, code39, itf, codabar, code93, code128
- str string content of the barcode
Usage:
escpos:barcode("code128", "HELLO WORLD!")
- setEmphasis (on)
-
Defines whether Emphasis will be activated.
Parameters:
- on boolean true(activate) or false(deactivate)
Usage:
escpos:setEmphasis(true)
- setJustification (justification)
-
Define the type of justification to use.
Parameters:
- justification
Types of justification:
escpos.JUSTIFY_LEFT escpos.JUSTIFY_CENTER escpos.JUSTIFY_RIGHT
Usage:
escpos:setJustification(escpos.JUSTIFY_CENTER) - justification
- setFont (font)
-
Define what type of font to use.
Parameters:
- font
Type of fonts:
escpos.FONT_A (escpos.MODE_FONT_A) escpos.FONT_B (escpos.MODE_FONT_B)
Usage:
escpos:setFont(escpos.MODE_FONT_A) - font
- feed (nl)
-
Send a feed.
Parameters:
- nl integer
Usage:
escpos:feed(2)
- text (text)
-
Send a text with line break.
Parameters:
- text string
Usage:
escpos:text("HELLO WOLRD!!")
- print_qrcode (content, err_co, size, model)
-
Print the given data as a QR code on the printer.
Parameters:
- content string the content of the code
- err_co
QR error-correction level to use:
escpos.QR_ERR_CO_LEVEL_L escpos.QR_ERR_CO_LEVEL_M escpos.QR_ERR_CO_LEVEL_Q escpos.QR_ERR_CO_LEVEL_H - size integer Pixel size to use. must be from 1 to 16 (default 3).
- model
Define the QR code model to use.
escpos.QR_MODEL_1 escpos.QR_MODEL_2 escpos.QR_MICRO
Usage:
escpos:print_qrcode("QR TESTING", escpos.QR_ERR_CO_LEVEL_M, 4, escpos.QR_MODEL_2)
- cut (mode, lines)
-
Cut the paper.
Parameters:
- mode
cut modes:
escpos.CUT_FULL (default) escpos.CUT_PARTIAL - lines integer integer
- mode