I am creating a desktop application in Node.Js using Electron framework and want to get the list of all the printers installed/connected in Node.Js. I had already tried node-printer but it is not installing properly.
I am creating a desktop application in Node.Js using Electron framework and want to get the list of all the printers installed/connected in Node.Js. I had already tried node-printer but it is not installing properly.
const { exec } = require('child_process');
exec('wmic printer list brief', (err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
return;
}
// list of printers with brief details
console.log(stdout);
// the *entire* stdout and stderr (buffered)
stdout=stdout.split(" ");
var printers=[];
j=0;
stdout = stdout.filter(item => item);
for (i = 0; i < stdout.length; i++)
{
if(stdout[i]==" \r\r\n" ||stdout[i]=="\r\r\n")
{
printers[j]=stdout[i+1];
j++;
}
}
// list of only printers name
console.log(printers);
console.log(stderr);
});
check this node package. https://www.npmjs.com/package/zuzel-printer
var Printer = require('zuzel-printer');
// Get available printers list
Printer.list();
If you target Windows machines you could use winreg package to search the Registry for printers. All local printers can be found at
HKEY_LOCAL_MACHINE | SYSTEM | CurrentControlSet | Control | Print | Printers
, the network printers in
HKEY_LOCAL_MACHINE | SYSTEM | CurrentControlSet | Control | Print | Providers | LanMan Print Services | servers | printers