Create a new Network printer instance.
Network configuration options
Configuration options for the Network printer.
IP address or hostname of the printer
Optionalport?: numberTCP port to connect to (default: 9100)
OptionalprofileName?: stringPrinter profile name to use (default: 'default')
Optionaltimeout?: numberConnection timeout in milliseconds (default: 5000)
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.
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).
Wait for all buffered writes to be flushed to the OS TCP stack.
Call this after the last _raw() write in a print job to guarantee all
data reaches the printer before close() destroys the socket.
Promise that resolves when the socket 'drain' event fires, or
immediately if there is nothing to drain.
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).
Open a TCP connection to the printer.
Resolves when the socket successfully connects. Rejects with DeviceNotFoundError if connection fails or times out.
Promise that resolves when connected
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).
Read data from the printer.
Resolves with up to length bytes received from the 'data' event.
If length is not specified, returns the full first data chunk received.
Optionallength: numberMaximum number of bytes to read (optional)
Promise resolving with a Buffer containing received data
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.
Network (TCP/IP) printer implementation.
Connects to an ESC/POS printer over a TCP socket using Node.js
net.Socket.Example
Since
1.0.0