-
Notifications
You must be signed in to change notification settings - Fork 0
Printer Status
Kyle La Barge edited this page Mar 16, 2019
·
3 revisions
- ✅ 2.1 | ⛔ 2.0 | ⛔ 1.9 | ...
- Retrieve status information from printers (.e.g. out of paper, offline, etc.).
Select the printers to get statuses on
qz.printers.startListening("ZDesigner LP2844"); // specific printer
qz.printers.startListening(); // all printers
// using arrow functions
var printerName = "ZDesigner LP2844"; // leave empty for all
qz.printers.startListening(printerName).then(() => console.log("Started listening for", printerName))
.catch(err => console.error(err));
Setup a callback to fire when status changes
qz.printers.setPrinterCallbacks(function(evt) {
console.log(evt.message, evt.severity);
});
// using arrow functions
qz.printers.setPrinterCallbacks(evt => console.log(evt.severity, evt.event))
.catch(err => console.error(err));
Get the current status of the printer
qz.printers.getStatus();
Stop listening to all printers
qz.printers.stopListening();
// using arrow functions
qz.printers.stopListening().then(() => console.log("Stopped listening"))
.catch(err => console.error(err));
//setup a callback
qz.printers.setPrinterCallbacks(function(evt) {
console.log(evt.message, evt.severity);
});
function getPrintersStatus () {
// get the printer, and pass it into the next function
qz.printers.find("Printer Name").then(function(printer) {
// listen to the printer
qz.printers.startListening(printer).then(function(){
// get the status
qz.printers.getStatus().then(function() {
});
});
}).catch(function(e) { console.error(e); });
};