libepos

Tooling for the Epson Point of Sale System, including XML generation and minimal HTTP handling.

Tested against an Epson TM-m30.

Not stable yet! API stability is not a guarantee.

Source :: npm :: jsr

Examples

Print a minimal example receipt

import { Printer } from 'jsr:@memdmp/libepos/print';
import {
  EposAlign,
  EposFeed,
  EposFont,
  EposPrint,
  EposText,
  EposCut,
  EposCutType,
} from 'jsr:@memdmp/libepos/xml';

const printer = new Printer(Deno.env.get('PRINTER_URL'), 'local_printer');

printer
  .print_unchecked(
    new EposPrint().append(
      new EposText()
        .align(EposAlign.Center)
        .setSize(2, 2)
        .setFont(EposFont.FontB)
        .setTextLn('Example'),
      new EposFeed().units(15),
      new EposText().setSize(1, 1).setFont(EposFont.FontC),
      new EposText('Tomatosuppenverkaufstelle\n'),
      new EposText('1234 Beispielstadt\n'),
      new EposText('Lichtenstein\n'),
      new EposFeed(),
      // ... Print the actual receipt information here ...
      new EposCut(EposCutType.Feed)
    )
  )
  .then((response) => console.log(response));

Print a receipt and a ticket with an aztec code

import { Printer } from 'jsr:@memdmp/libepos/print';
import {
  EposAlign,
  EposFeed,
  EposPrint,
  EposText,
  EposCut,
} from 'jsr:@memdmp/libepos/xml';
import { EposAztec } from 'jsr:@memdmp/libepos/scannable';

const printer = new Printer(Deno.env.get('PRINTER_URL'), 'local_printer');

printer
  .print_unchecked(
    new EposPrint().append(
      new EposText(`
...some text here...
-----------------------
* Customer Receipt *
Payment Method:
Catgirlcard contactless
************1234
-----------------------
...some text here...
    `)
        .align(EposAlign.Center()),
      new EposCut(),
      new EposText(`
    ...some text here...
    Your Product:
    `)
        .align(EposAlign.Center()),
      new EposFeed().units(30),
      new EposAztec(
        new Uint8Array(ticketData)
      ),
      new EposCut(),
    )
  ).then((response) => console.log(response));