node-escpos-windows
v1.1.4
Published
a cpp escpos plugin for nodejs and electron
Downloads
17
Maintainers
Readme
npm i node-escpos-windows --build-from-source --runtime=electron --target=7.1.2 --target-arch=ia32 --dist-url=https://atom.io/download/electron
#escpos native plugin for electron
#目前只支持 windows系统
// usb printer
const iconv = require('iconv-lite');
const escpos =require('node-escpos-windows');
const usblist = escpos.GetUsbDeviceList();
const printer = usblist.find(item => item.service ==='usbprint' || item.deviceName==='USB 打印支持');
const content = iconv.encode("你好啊\n halo cpp!\\n\n\n\n\nn\n\n\n\n", 'GB18030');
const {success, err} = escpos.PrintRaw(printer.path, content);
// lpt printer
const iconv = require('iconv-lite');
const escpos =require('node-escpos-windows');
const lptList = escpos.GetLptDeviceList();
const printer = lptList[0];
const content = iconv.encode("你好啊\n halo cpp!\\n\n\n\n\nn\n\n\n\n", 'GB18030');
const {success, err} = escpos.PrintRaw(printer.path, content);
// disconnect
const isDisConnected = escpos.Disconnect(printer.path);