webContents.print fails to print on Windows


#1

I am trying to build print functionality into an Electron app.
My print code is as simple as the following:

mainWindow.webContents.print( {}, function(response){
  console.log(response);
});

My expectation is that this should open a print dialog and that the OS will handle printing from there.

This is working fine on my Mac, and I’ve had it working fine on one Windows 10 PC, but the exact same code is not working on any other Windows 10 PC. The print dialog appears, I can select the right printer and continue, but after a few seconds the callback returns false and nothing prints.

There doesn’t seem to be any way to even diagnose what error is occurring, so I am baffled. The printer works fine from other apps, and my Electron app can print fine elsewhere. Is it known that this doesn’t work on certain versions of Windows, or might some sort of permissions need granting? Any ideas? Thank you