Documentation
Printer Status
- ✅ 2.2 | ✅ 2.1 | ⛔ 2.0 | ⛔ 1.9 | ...
- Retrieve status information from printers (.e.g. out of paper, offline, etc.).
- Listen for printer status
- Setup Callback
- Get Status
- Sample Event
- Full Example
- Printer and Job Statuses
- Advanced
Select the printers to get statuses on using qz.printers.startListening(...)
// Specific printer
qz.printers.startListening("ZDesigner LP2844")
.catch(err => console.error(err);
// All printers
qz.printers.startListening()
.catch(err => console.error(err)
// Based on best-match
qz.printers.find("ZDesigner").then(printer => {
console.log("Listening for printer events", printer));
return qz.printers.startListening(printerName);
}).catch(err => console.error(err));Setup a callback to fire when status changes and request status using qz.printers.setPrinterCallbacks(...) and request immediate status using qz.printers.getStatus().
qz.printers.setPrinterCallbacks(evt => console.log(evt.severity, evt.eventType, evt.message));
qz.printers.getStatus().then(() => console.log("Listening on printer status"));
.catch(err => console.error(err));{
printerName: "PDFwriter",
jobName: "My Sample PDF", /* since 2.1.3 */
eventType: "JOB", /* since 2.1.3 */
statusText: "PAUSED", /* since 2.1.3 */
severity: "WARN",
statusCode: "media-empty", // (or for Windows, 0x00000040) /* since 2.1.3 */
message: ...
}Gets the most recent status of all printers that are currently being listened to using qz.printers.getStatus(...). Assumes a listener has already been added. This is helpful for when a status arrived prior to listening, the most recently stored status should be delivered.
// Request the current status of all printers
qz.printers.getStatus().then(() => console.log("Requesting all printer statuses for listened printers"))
.catch(err => console.error(err));Stop listening to all printers
qz.printers.stopListening().then(() => console.log("Stopped listening"))
.catch(err => console.error(err));Job Statuses and Printer Statuses are captured by CUPS or Winspool and mapped to generic statuses. See also: src/qz/printer/status/job, src/qz/printer/status/printer.
-
eventType: "JOB"severitystatusText❌ ERRORABORTED❌ ERRORERROR❌ ERROROFFLINE⚠️ WARNCANCELED⚠️ WARNPAPEROUT⚠️ WARNRESTART⚠️ WARNUSER_INTERVENTION✅ INFOCOMPLETE✅ INFODELETED✅ INFODELETING✅ INFOPRINTING✅ INFOSPOOLING✅ INFOSCHEDULED✅ INFORETAINED✅ INFOPAUSED✅ INFOSENT✅ INFORENDERING_LOCALLY✅ INFOUNKNOWN💀 FATALUNMAPPED -
eventType: "PRINTER"severitystatusText💀 FATALERROR💀 FATALPAPER_JAM💀 FATALOFFLINE💀 FATALNOT_AVAILABLE💀 FATALNO_TONER💀 FATALPAGE_PUNT💀 FATALOUT_OF_MEMORY💀 FATALUNMAPPED⚠️ WARNPAUSED⚠️ WARNPAPER_OUT⚠️ WARNPAPER_PROBLEM⚠️ WARNPENDING_DELETION⚠️ WARNOUTPUT_BIN_FULL⚠️ WARNTONER_LOW⚠️ WARNUSER_INTERVENTION⚠️ WARNDOOR_OPEN⚠️ WARNSERVER_UNKNOWN✅ INFOOK✅ INFOMANUAL_FEED✅ INFOIO_ACTIVE✅ INFOBUSY✅ INFOPRINTING✅ INFOWAITING✅ INFOPROCESSING✅ INFOINITIALIZING✅ INFOWARMING_UP✅ INFOPOWER_SAVE✅ INFOUNKNOWN
//setup a callback
qz.printers.setPrinterCallbacks((evt) => { console.log(evt.severity, evt.eventType, evt.message); });
function getPrintersStatus () {
// get the status of a specific printer
qz.printers.find("Printer Name").then(printer => {
// listen to the printer
qz.printers.startListening(printer).then(() => {
return qz.printers.getStatus();
});
}).catch(function(e) { console.error(e); });
};Since 2.2.2, QZ Tray has the ability to receive raw job data (e.g. .PRN file), but has the following requirements:
-
This feature is Windows only (this feature is not yet supported on macOS, Linux)
-
User must be able to read the spool file location
-
qz-tray.propertiesmust be modified to toggle this feature on or you will receive the errorJob data listeners are currently disabled.#Wed Dec 14 16:16:09 EST 2022 printer.status.jobdata=true
-
An additional parameter
jobDatamust be provided to startListening(...).var options = { jobData: true, // toggle job data }; qz.printers.startListening(null /* all printers */, options);
-
The format and size of the data can be manipulated using
flavorandmaxJobData, respectively.var options = { jobData: true, // toggle job data flavor: 'base64', // return spool file content as 'base64' (default is 'plain') maxJobData: 64 // only return data less than or equal to 64 bytes (default is -1) }; qz.printers.startListening(null /* all printers */, options);
