Skip to content

Repository files navigation

@node-escpos



🖨️ ESC/POS Printer driver for Node.js.


Hacktober Badge


demo.mp4

[📢 RFC] Recently I'm working on a new workflow that prints the receipt. HTML+CSS will customize the content. Theoretically, we can print anything that we want. The workflow is like this:

  1. 🎨 rendering
<divid="label-dom"> Label/Receipt </div>
  1. 📸 capturing
constscreenshort=awaitcapture(document.getElementByID("label-dom"))
  1. 🧾 printing
constprinter=awaitprinter.image(screenshort,"s8")printer.cut().close()

But my full-time job is very busy. So the progress is slow, And any sponsorship will encourage me to work more actively in the open-source community.


Improvements

  • 🛠 TypeScript.
  • 📦 pnpm.
  • 🟢 vitest.
  • 🚀 More stable maintenance.
  • 🔴 Printing by HTML+CSS(WIP).
  • 💡 More ideas.
  • ...

Packages

Example

import{Printer,Image}from"@node-escpos/core";// install escpos-usb adapter module manuallyimportUSBfrom"@node-escpos/usb-adapter";// Select the adapter based on your printer typeimport{join}from"path";constdevice=newUSB();device.open(asyncfunction(err){if(err){// handle errorreturn}// encoding is optionalconstoptions={encoding: "GB18030"/* default */}letprinter=newPrinter(device,options);// Path to png imageconstfilePath=join("/PATH/TO/IMAGE");constimage=awaitImage.load(filePath);printer.font("a").align("ct").style("bu").size(1,1).text("May the gold fill your pocket").text("恭喜发财").barcode(112233445566,"EAN13",{width: 50,height: 50}).table(["One","Two","Three"]).tableCustom([{text: "Left",align: "LEFT",width: 0.33,style: "B"},{text: "Center",align: "CENTER",width: 0.33},{text: "Right",align: "RIGHT",width: 0.33},],{encoding: "cp857",size: [1,1]},// Optional)// inject qrimage to printerprinter=awaitprinter.qrimage("https://github.com/node-escpos/driver")// inject image to printerprinter=awaitprinter.image(image,"s8"// changing with image)printer.cut().close()});

Sponsors

License

MIT License © 2022 Dohooo

Releases

Sponsor this project

Packages

Used by

Contributors

Languages