In NWJS, I would like to open a popup window with a local file URL to a PDF and then print the PDF right away (on Windows). I tried doing this:
nw.Window.open(
'file://' + downloadItem.filename.replace(/\\/g, '/'),
{new_instance: true, height: 600, width: 800},
function(pdfWin) {
pdfWin.on('loaded', function() {
this.print({autoprint: false});
});
}
);
But in the developer tools, it says that pdfWin
is undefined, which is completely weird to me considering that it should work according to the documentation. I then tried using Window.open
with nw.Window.get() and then but I get an error saying Blocked a frame with origin "chrome-extension://..." from accessing a cross-origin frame.
Any ideas?
Alright, I found the problem. The code above works if you take out new_instance: true
. If that variable is marked as true
, then this
is undefined
initially and the code doesn't work.