node-printer-escpos
node-printer-escpos
example
let Printer = require('./main')
let { esc, Image, getPixels, getPrinters } = Printer
let usbPrinter = getPrinters().find(p => {
return p.portName === 'USB001'
})
const printer = new Printer(usbPrinter.name)
print text
esc = new esc({}, {})
esc.init().text('这里打印第一行吧?123!').flush()
printer.print(esc.buffer._buffer)
print text、barcode、qrcode(可以设置二维码大小)
esc
.init()
.text('test print qrcode')
.text('测试下打印二维码')
.align('CT')
.barcode('1234567', 'EAN8')
.qrimage('https://vip.com', {width: 200, height: 'auto'}, function(err){
this.flush()
printer.print(this.buffer._buffer)
})
print custom image
getPixels('https://b.appsimg.com/upload/momin/2019/02/21/133/1550737570483.png', function(err, pixels) {
this.image(new Image(pixels))
this.flush()
printer.print(esc.buffer._buffer)
})
thanks
https://github.com/tojocky/node-printer
https://github.com/song940/node-escpos
https://github.com/alexeyten/qr-image
https://github.com/scijs/get-pixels
nd so on/etc.