Wiki - Data Filtering

Compatibility

Objective

Prerequisites

Contents

Printer Details

Note: The sift.js library is not needed for this.

You can get various printer information (driver, densities, default printer, trays) for system attached printers

qz.printers.details();

The result is returned as an object array

Loop through your results

function detailPrinters() {
    qz.printers.details().then(function(data) {
        for(var i = 0; i < data.length; i++) {
            console.log(data[i].name + " " + data[i].driver + " " + data[i].density + " " + data[i].trays);
        }
    }).catch(function(e) { console.error(e); });
}

Basic Syntax

Remove whatever matches the option from the data object

sift.toss(data, { option });

Keep whatever matches the option criteria from the data object

sift.keep(data, { option });

Printers

Per the sift library:

QZ Tray has a built-in function qz.printers.details(); that meets this criteria

Virtual Printers

The sift library can be used to filter out virtual printers. This can be useful for preventing a user from printing, for example, coupons to a PDF printer.

function detailPrinters() {
   qz.printers.details().then(function (data) {
       data = sift.keep(data, { physical: true }); //same as sift.toss(data, { physical: false });
       console.log(data);
   }).catch(function(e) { console.error(e); });
}
function detailPrinters() {
   qz.printers.details().then(function (data) {
       data = sift.keep(data, { physical: false }); //same as sift.toss(data, { physical: true });
       console.log(data);
   }).catch(function(e) { console.error(e); });
}

Raw Printers

Return only raw printers

function detailPrinters() {
    qz.printers.details().then(function (data) {
        data = sift.keep(data, { type: 'raw' });
        console.log(data);
    }).catch(function(e) { console.error(e); });
}

Network Information

MAC Address Filtering

Physical Adapter Virtual Adapter
burnedIn: true burnedIn: false

Return only physical adapters

function listNetworkDevices() {
   qz.networking.devices().then(function(data) {
      data = sift.keep(data, {burnedIn: true });
      console.log(data);
   }).catch(function(e) { console.error(e); });
}

Scales

Edit this page