AbstractOptionalprofileName: stringPrinter profile name from the capabilities database
(e.g. "TM-T88V"). Defaults to "default".
See ProfileManager.listProfiles for available names.
Abstract_Send a raw Buffer of bytes directly to the printer hardware.
All higher-level methods ultimately call this. Subclasses must implement it to write to the underlying transport (TCP socket, USB endpoint, etc.).
Buffer containing ESC/POS command bytes.
Print a hardware barcode.
Sends the appropriate GS k sequence for the requested barcode type and
function type. Supports all types defined in BARCODE_TYPES
(UPC-A, UPC-E, EAN8, EAN13, CODE39, ITF, NW7/CODABAR, CODE93, CODE128,
and GS1 variants for Function Type B).
Barcode data string.
Barcode type name (e.g. 'CODE128', 'EAN13').
Names are normalised (non-alphanumeric removed, uppercased) before lookup.
Optional barcode appearance settings; see BarcodeOptions.
BarcodeTypeError if the type is unrecognised or unsupported.
BarcodeCodeError if code fails format validation and
opts.check is true (default).
BarcodeSizeError if height or width are out of range.
Print a word-wrapped text block.
Wraps txt at word boundaries to fit within the column width of the
selected font, as reported by the active printer profile.
UTF-8 string to wrap and print.
Font to use for column-width lookup ('a' or 'b'; default: 'a').
Optionalcolumns: numberOverride column count (uses profile value if omitted).
Send a cash-drawer open pulse.
Cash-drawer pin: 2, 5, or a 5-element array
[esc, p, m, t1, t2] for a custom DEC sequence.
CashDrawerError if pin is not 2, 5, or a valid 5-element array.
AbstractcloseClose the connection to the printer and release all resources.
Safe to call even if not connected. Subclass behaviour:
Promise that resolves when all resources have been released.
Cut the paper.
Feeds 6 lines before cutting unless feed is false. Falls back to a
full cut when the profile does not support partial cuts, and vice versa.
'FULL' (default) for a complete cut, 'PART' to leave
a small uncut section.
Feed paper before cutting (default: true).
Send a hardware control command to the printer.
| Action | Command | Effect |
|---|---|---|
'INIT' |
ESC @ |
Clear print buffer and reset modes to defaults |
'SELECT' |
ESC = |
Select printer as the active peripheral |
'RESET' |
ESC ? |
Soft reset |
One of 'INIT', 'SELECT', or 'RESET'.
Print an image from a file path or raw image Buffer.
Supported formats: PNG, JPEG, BMP, GIF, TIFF.
The image is:
fragmentHeight.impl and written via _raw().impl options:
'bitImageRaster' (default) — GS v 0; widest printer compatibility.'graphics' — GS ( L; better alignment on some models.'bitImageColumn' — ESC *; required for printers like IT80-002.Absolute file path or raw image Buffer.
Image rendering options; see ImageOptions.
ImageWidthError if the image is wider than the profile's declared media width.
Open the line display, clear it, write text, then close it.
Convenience wrapper around linedisplaySelect, linedisplayClear, and Escpos.text.
Text to display on the customer-facing line display.
Set or reset the line spacing.
When called without arguments, resets line spacing to the printer default
(ESC 2). When spacing is provided, sets the line spacing to
spacing / divisor inches per dot using the matching ESC/POS command:
| Divisor | Command | Range |
|---|---|---|
| 60 | ESC A |
0–85 |
| 180 | ESC 3 |
0–255 |
| 360 | ESC + |
0–255 |
Optionalspacing: numberSpacing value in dots (omit to reset).
Unit divisor: 60, 180, or 360 (default: 180).
AbstractopenOpen the connection to the printer.
Must be called before any print commands are sent. Subclass behaviour:
Promise that resolves when the printer is ready to accept data.
Print a QR code.
Two rendering modes are available, controlled by opts.native:
Software mode (native: false, default) — generates the QR matrix
locally using the qrcode package and sends it as a raster image via
image. Works on all printers that support raster images.
Native mode (native: true) — sends the five GS ( k sub-commands
(set model, size, error correction, store data, print) directly.
Requires the printer to have a built-in QR engine (most Epson TM series).
Apply ESC/POS text style attributes.
Each field in opts that is defined emits the corresponding ESC/POS
command immediately. Omitted fields are not changed on the printer.
For size changes, exactly one of customSize, doubleWidth,
doubleHeight, or normalTextSize should be set.
Style attributes to apply; see TextStyleOptions.
SetVariableError if customSize is set but width or
height is outside the 1–8 range.
Apply text styles with full defaults merged in.
Merges opts over a complete default set (left align, Font A, no
bold, no underline, 1×1 size, density 9) before calling set.
Also auto-enables customSize when width or height > 1 is requested
without an explicit size mode, so callers do not need to set the flag manually.
Calling with no arguments resets the printer to standard text defaults.
Partial style overrides (default: {} — full reset).
Print a row of text in software-defined columns.
Lays out textList into adjacent fixed-width columns, word-wrapping each
cell and aligning content per the corresponding align entry. Outputs
one textln() call per row of the resulting grid.
Print a string using automatic encoding selection.
Characters are encoded via MagicEncode, which automatically
selects the best code page for each segment of the string and emits
the necessary ESC t n code-page-switch commands.
UTF-8 string to print.
StaticcheckValidate a barcode code string against the format rules for a given barcode type.
Checks that the code length falls within an allowed range and that the string matches the required character set for the barcode type.
Barcode type name (e.g. 'CODE128', 'EAN13').
Barcode data string to validate.
true if the code is valid for the given type.
Abstract base class for ESC/POS thermal receipt printers.
Provides the complete ESC/POS formatting API — text, styles, barcodes, QR codes, and images. Hardware transport is handled by subclasses:
net.Socket.usbnpm package (libusb).Subclassing: Implement
_raw(data: Buffer): void,open(): Promise<void>, andclose(): Promise<void>. All other methods are provided by this class.Example
Since
1.0.0