Sending dynamic polymer content to a print window in Electron 2.0.12

Hello! My problem is a bit of a unique one as my company is using Polymer 3 and Electron 2.0.12 – project is a little older. Our project is multi-layered and dynamic; the issue is that I’m trying to duplicate the content in the main window and feed it into a modal window for printing. The format for the content is very wrong while the content itself is present in the content variable when calling it in dev tools while only a few elements are present in the window.

var content = getMyContent();
content = content.shadowRoot.innerHTML;
const electron = require(‘electron’);
const remote = electron.remote;
const BrowswerWindow = remote.BrowserWindow;

printWindow = new BrowserWindow({
modal: true,
show: true,
height: 600,
width:800
});

printWindow.loadURL(“data:text/html;charset=utf-8,” + encodeURI(content));
printWindow.webContents.print();

The content is correct when run in the dev tools. I’ve also inserted the snippet (html) below in place of content and it works just fine:

var html = [
“”,

It works

”,

Actually it doesn’t

”,

I wish it would

”,

That’d be super great

”,
I know I’m close though!
”,
Maybe not…
”,
“”,
].join("");

Does anyone have any insight into what’s happening? My lead and I both are stumped…

Assuming your code is setting the content correctly it could be trying to print before the content has loaded in the window. Try calling the print command after the content has definitely finished loading (use the callbacks)