@product-simple/escpos
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@product-simple/escpos npm

BETA

Motivation

Most thermal printers on the market support the ESC/POS command protocol made by EPSON (Reference). There seems to be a lack of options when it comes to using typescript to support this protocol. This library serves one fundamental purpose; provide a typescript builder pattern library for constructing ESC/POS compatible buffers in Node.js.

Getting Started

Start by installing the package with your favorite package manager.

Using npm

npm i @product-simple/escpos

Using yarn

yarn add @product-simple/escpos

Using pnpm

pnpm add @product-simple/escpos

Once installed, simply import the package and start building escpos compatible buffers.

import {
  DocumentBuilder,
  DocumentBuilderFormatOptions,
  DefaultFormatter,
  FormatTextAlign,
  FormatTextUnderline,
  NetworkPrinter,
} from '@product-simple/escpos';

// create the builder with default formatting
const builder = new DocumentBuilder(
  new DefaultFormatter({
    align: FormatTextAlign.Left,
    bold: false,
    underline: FormatTextUnderline.None,
  }),
);

// build our print document
const buffer = builder
  .text('Line 1')
  .text('Line 2')
  .format({ draw: (b) => b.text('underlined text'), underline: FormatTextUnderline.TwoDot })
  .cut()
  .build();

// create and connect to the printer
const printer = await NetworkPrinter.create({
  port: 9100,
  host: '192.168.1.87',
});
await printer.write(buffer);
await printer.close();

Features

  • [x] Text
  • [x] Text line
  • [ ] Feed line
  • [x] Bold text
  • [x] Underline text
  • [ ] Font size
  • [ ] Small mode
  • [ ] White mode
  • [x] Align
  • [ ] Barcode
  • [ ] QRcode
  • [x] Paper cut node
  • [ ] Image (base64) (png only)

Package Sidebar

Install

npm i @product-simple/escpos

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

72.7 kB

Total Files

37

Last publish

Collaborators

  • joe_hartzell