thiagoelg / node-printer

Native node.js printer
125 stars 75 forks source link

Getting type error when trying to call printDirect #35

Closed PimTournaye closed 2 years ago

PimTournaye commented 2 years ago

This is the error I get Error: Argument 1 must be a string at printDirect (/home/pi/arbre/bixolon-printer/node_modules/@thiagoelg/node-printer/lib/printer.js:242:38) at Printer.printRaw (file:///home/pi/arbre/bixolon-printer/printer.js:21:9) at Timeout._onTimeout (file:///home/pi/arbre/bixolon-printer/main.js:70:24) at processTicksAndRejections (internal/process/task_queues.js:97:5)

This is my code

printRaw(text){
        console.log(typeof text);
        let modifiedText = "\n \n" + text + "\n \n \n \n" 
        console.log('printing now');
        printDirect({
            data: Buffer.from(INITIAL_PRINTER) + Buffer.from(modifiedText) + Buffer.from(PAPER_CUTTING) + Buffer.from(PAPER_EJECT) , 
            printer:this.name,
            type: "RAW",
            success:function(){ console.log("printed: \n"+text + '\n \n');},
            error:function(err){console.log(err);}
        });
    }

This happened using the newest version

PimTournaye commented 2 years ago

Nevermind, did something stupid, all is fine.

ztomaz commented 1 year ago

@PimTournaye Is it possible for you to share the solution. I am facing same problems after using the newest version

riquemoraes commented 1 year ago

@ztomaz Are you using Electron? If so, update to the last version of Electron, it worked with me.