node-printer
node-printer copied to clipboard
TypeError: Argument 1 must be a string in win10 and Electron
I met this problem when we wanted to print file(png) in the window ELectron project, The code is as follows
printer.printDirect({
data: fs.readFileSync(fileName),
printer: printe,
success: function (jobID) {
console.log("sent to printer with ID: " + jobID);
res();
},
error: function (err) {
rej(err);
}
});
so how can i print a file or png in an Electron project
Also using Electron and got this error.
It was caused by passing something other than a string into the printer
property.
printer.printDirect({
data: fs.readFileSync(fileName),
printer: printe, // <- almost certainly not a string, probably undefined
success: function (jobID) {
console.log("sent to printer with ID: " + jobID);
res();
},
error: function (err) {
rej(err);
}
});
Once I got an actual printer name into the printer
property it worked perfectly.
@dogLin this works for me https://github.com/Ronalses/printer-electron-epson-TM-T88V