lsongdev / node-escpos

🖨️ ESC/POS Printer driver for Node.js
https://npmjs.org/escpos
Other
1.38k stars 423 forks source link

[FEAT]: how to get printer list #437

Open Boolean2023 opened 1 month ago

Boolean2023 commented 1 month ago

Description

is there a way to retrieve the list of printers paired on the machine with this package? if so, how do I get there?

Additional Information

Printers list node-escpos

Psychopoulet commented 1 month ago

with the embeded "usb" package, like this ?

`` usb.getDeviceList().filter((device) => { // has interfaces

return device && device.configDescriptor && device.configDescriptor.interfaces && device.configDescriptor.interfaces.length;

}).map((device) => { // formate

const interfaces = [];

device.configDescriptor.interfaces.forEach((its) => {

    its.forEach((it) => {

        interfaces.push({
            "id": it.bInterfaceNumber,
            "type": it.bInterfaceClass
        });

    });

});

return {
    "bus": device.busNumber,
    "port": device.deviceAddress,
    "vid": device.deviceDescriptor.idVendor,
    "pid": device.deviceDescriptor.idProduct,
    "interfaces": interfaces
};

}).filter((device) => { // only printers

return !!device.interfaces.find((it) => {
    return 7 === it.type;
});

}); ``

tamil752002 commented 1 month ago

can i get Printer List , which is Connect My Lan Network ? is this Possible

Psychopoulet commented 1 month ago

You may try to scan every IP on your network with an escpos ping and check which one is responding, I guess ?

Boolean2023 commented 1 month ago

OK Thanks