Nw.js: Autoprint is not completely silent

Created on 2 Nov 2017  路  7Comments  路  Source: nwjs/nw.js

NWJS Version : 0.26.3
Operating System : Mac OS 10.13

Expected behavior

When the main window is hidden, printing with autoprint: true should send document to printer quietly without any pop ups.

Actual behavior

Main window appears on screen, print preview dialog flashes momentarily, then the printing starts.

How to reproduce

I created an app that sits in system tray and waits for specific data. When it gets that data, it prints a label on a label printer attached directly to the computer.
To mitigate the problem somewhat, I added win.hide() right after printing. It hides the window no problem, however during the brief moment while the main window appears, it takes the focus away from whatever app it was in before.
Is it possible to keep the main window always hidden? Or to print from some background window that is never visible in the first place?

package.json:

{
  "name": "helloworld",
  "main": "index.html",
  "window": {
    "show": false,
    "show_in_taskbar": false
  }
}

relevant part of index.html:

win.print({
    autoprint: true, // do not display confirmation dialog
    printer: printer.deviceName,
    headerFooterEnabled: false,
    landscape: true,
    marginsType: 1, 
    mediaSize:{'name': 'Label', 'width_microns': 29000, 'height_microns': 89000, 'custom_display_name':'Label', 'is_default': true}
});
win.hide();

P3 bug triaged

Most helpful comment

It would be great if anyone could give us a rough estimate for this to be fixed. It's a pretty important issue for our use case (kiosk). I can see it's currently labeled as P3 which doesn't look very promising.

All 7 comments

I think this would be nice. I already had a pull request I forgot I opened to enable a better print API https://github.com/nwjs/nw.js/pull/4999 maybe I can add this as well?

I can reproduce this issue on Mac with nwjs-sdk-v0.26.6. There is no printer to connect to my Mac, so I use a virtual printer to test. The main window appears.

is there any update on this?

It would be great if anyone could give us a rough estimate for this to be fixed. It's a pretty important issue for our use case (kiosk). I can see it's currently labeled as P3 which doesn't look very promising.

is there any news on this?

This is fixed in git and will be available in the next nightly build of 0.44 branch.

The nightly build for this issue is available at https://dl.nwjs.io/live-build/nw44/20200116-162000/4f2576110

Was this page helpful?
0 / 5 - 0 ratings