node-printer icon indicating copy to clipboard operation
node-printer copied to clipboard

TypeError: Argument 1 must be a string in win10 and Electron

Open dogLin opened this issue 6 years ago • 2 comments

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

dogLin avatar May 29 '18 05:05 dogLin

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.

only-cliches avatar Jun 29 '18 11:06 only-cliches

@dogLin this works for me https://github.com/Ronalses/printer-electron-epson-TM-T88V

Ronalses avatar Aug 14 '18 15:08 Ronalses