Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const usb = require("webusb").usb;
- const escpos = require('escpos');
- function connect(){
- var vid;
- var pid;
- navigator.usb.requestDevice({ filters: [{ vendorId: 0x04b8 }] })
- .then(devicePrinter => {
- console.log(device.vendorId);
- console.log(device.productId);
- vid = device.vendorId.toString(16);
- pid = device.productId.toString(16);
- console.log(vid + pid);
- })
- .catch(error => { console.log(error); });
- const device = new escpos.USB("0x0"+vid, "0x0"+pid);
- const printer = new escpos.Printer(device);
- device.open(function(){
- printer
- .align('ct')
- .text("nice")
- .cut()
- .close();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement