Skip to main content

Installation and Usage

ESC-POS Printer Manager

GitHub stars GitHub forks GitHub watchers

ESC-POS Printer Manager All Versions - Tested on Windows 10 and Windows 11

What you'll need

esc-pos-printer (Javascript / Typescript) library

npm npm npm

npm install esc-pos-printer
# or
yarn add esc-pos-printer

Usage

YOU MUST HAVE A PRINTER CONFIGURED IN ADVANCE

If the printer is not configured, the esc-pos printer manager will not be able to detect it Please see: HOW TO SET UP PRINTER

See it live escpos-printer-example.netlify.app

EXAMPLE SOURCE CODE

import Printer from "esc-pos-printer";

const handlePrint = async () => {
try {
/* Create new printer */
const printer = new Printer();

/* get Printers list */
const printerList = await printer.getPrinters();

/* you can set the list in a state and use a select */
/* printerList[0] for this example */
printer.setPrinterName(printerList[0]);

/* for japanese and chinese text
printer.setPrinterTextAsian(true);
printer.text("こんにちは、これは機能します \n");
printer.text("你好,这有效 \n");
*/

/* EXPERIMENTAL
for use unifont chars
printer.text("IT WORKS!!! :D\n");
printer.text("Hola esto funciona\n");
printer.text("Ողջույն, սա աշխատում է: \n");
printer.text("こんにちは、これは機能します \n");
printer.text("안녕하세요 이게 작동해요 \n");
printer.text("你好,这有效 \n");
*/

printer.text("IT WORKS!!! :D\n");
printer.feed(2);
printer.cut();
printer.close();
await printer.print();
} catch (error) {
/* Handle error */
}
};