Web API print
This commit is contained in:
30
browser-print-api.js
Normal file
30
browser-print-api.js
Normal file
@ -0,0 +1,30 @@
|
||||
function getAvailablePrinters() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const devices = [];
|
||||
BrowserPrint.getDefaultDevice(
|
||||
"printer",
|
||||
(device) => {
|
||||
devices.push(device);
|
||||
const defaultDevice = device;
|
||||
|
||||
BrowserPrint.getLocalDevices((deviceList) => {
|
||||
deviceList?.printer.forEach(
|
||||
(device) => {
|
||||
if (!defaultDevice || device.uid != defaultDevice.uid) {
|
||||
devices.push(device);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
reject("Error getting local devices");
|
||||
},
|
||||
"printer"
|
||||
);
|
||||
resolve(devices);
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
reject(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user