🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

epson-tm-u220-driver

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

epson-tm-u220-driver

Small node.js util to send commands to Epson U220* receipt printers

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

Epson TM-U220* Printer Driver

A TypeScript driver for the Epson TM-U220* receipt printers. Since it uses standard ESC/POS commands, it may work with other compatible printers as well. I only tested it with the TM-U220IID model.

For general ESC/POS printer usage, I recommend using the escpos package. This driver is intended for cases where you need a minimal, specialized solution specifically for TM-U220* series printers.

Installation

npm install epson-tm-u220iid-driver

Usage

Basic Example

import PrinterBuffer, { Alignment, TextSize } from 'epson-tm-u220iid-driver';

const printer = new PrinterBuffer({
    portPath: '/dev/tty.usbserial',  // Your serial port path
    baudRate: 9600,                  // Optional, defaults to 9600
    autoOpen: true                   // Optional, defaults to true
});

// Simple print job
await printer
    .init()
    .text('Hello World!')
    .print();

// Formatted print job
await printer
    .init()
    .align(Alignment.CENTER)
    .size(TextSize.DOUBLE_HEIGHT)
    .text('Double height')
    .align(Alignment.LEFT)
    .init()
    .text('Regular text')
    .feed(3)
    .print();

await printer.close(); // Close the port when done

Text Formatting

The driver supports various text formatting options:

// Alignment
printer.align(Alignment.LEFT);
printer.align(Alignment.CENTER);
printer.align(Alignment.RIGHT);

// Text Size
printer.size(TextSize.NORMAL);
printer.size(TextSize.DOUBLE_HEIGHT);
printer.size(TextSize.DOUBLE_WIDTH);
printer.size(TextSize.DOUBLE_BOTH);

API Reference

Constructor Options

interface PrinterOptions {
    portPath: string;    // Path to the serial port
    baudRate?: number;   // Baud rate (default: 9600)
    autoOpen?: boolean;  // Auto-open port (default: true)
}

Methods

  • init(): Initialize the printer
  • text(text: string): Add text to the buffer
  • align(alignment: Alignment): Set text alignment
  • size(size: TextSize): Set text size
  • feed(lines: number = 2): Feed paper lines
  • clear(): Clear the print buffer
  • print(): Print the buffer contents
  • close(): Close the serial port

Enums

enum Alignment {
    LEFT = '\x1B\x61\x00',
    CENTER = '\x1B\x61\x01',
    RIGHT = '\x1B\x61\x02'
}

enum TextSize {
    NORMAL = '\x1B\x21\x00',
    DOUBLE_HEIGHT = '\x1B\x21\x10',
    DOUBLE_WIDTH = '\x1B\x21\x20',
    DOUBLE_BOTH = '\x1B\x21\x30'
}

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

FAQs

Package last updated on 07 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts