Angular 5 electron POS print


#1

Hi,

I have epson tm-t82 roller printer and I am trying to print an invoice.

In main.js file

mainWindow = new BrowserWindow({
    show: false,
    backgroundColor: '#ffffff',
    webPreferences: {
      nodeIntegration: false,
      preload: __dirname + '/preload.js'
    }
  })

and in preload.js, I have written the function to create print the content using node-thermal-printer as

 var printer = require("node-thermal-printer");
window.printFunction = (data) => {
    printer.init({
        type: 'epson'
    });
    printer.alignCenter();
    printer.println("Hello world");
    printer.cut();
    printer.execute(function (err) {
        if (err) {
            console.error("Print failed", err);
        } else {
            console.log("Print done");
        }
    });
}

And I am calling printFunction from my angular code but I am getting

ERROR ReferenceError: setImmediate is not defined

Also, there is no callback or any response to the print.

I am missing something? Can anyone suggest the correct way or any working solution for POS printing with angular and electron