<p dir="auto">Electron Version:<br>
4.0.6<br>
Operating System:<br>
windows 10 1803<br>
Expected Behavior<br>
It shd print using PrintToPDF() when requested from the renderer</p>
<p dir="auto">Actual Behavior<br>
Upon the print request everything freezes</p>
<p dir="auto">To Reproduce<br>
//RENDERER<br>
await ipc.sendSync("ExecuteBackendFx", { fxName: "PrintToPDF", fxArgs: null });<br>
//MAIN<br>
global.PrintToPDF = async () =&gt; {<br>
let out = await new Promise((resolve, reject) =&gt; {<br>
mainWindow.webContents.printToPDF(<br>
{<br>
marginsType: 0,<br>
printBackground: false,<br>
printSelectionOnly: false,<br>
landscape: false<br>
},<br>
function(error1, data1) {<br>
fs.writeFile(rootDir + "/UI/Temp/print.pdf", (data1, error1) =&gt; {<br>
resolve("Success");<br>
});<br>
}<br>
);<br>
}<br>
});</p>
<p dir="auto">return out;<br>
}</p>
<p dir="auto">Additional Information<br>
It prints normally when the request comes from the backend directly.for eg calling the function directly from the debug on VSCODE</p>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>4.0.6</li>
</ul>
</li>
<li><strong>Operating System:</strong><br>
windows 10 1803</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">It shd print using PrintToPDF() when requested from the renderer</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">Upon the print request from the renderer using await everything freezes</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">//RENDERER<br>
await ipc.sendSync("ExecuteBackendFx", { fxName: "PrintToPDF", fxArgs: null });<br>
//MAIN<br>
global.PrintToPDF = async () =&gt; {<br>
let out = await new Promise((resolve, reject) =&gt; {<br>
mainWindow.webContents.printToPDF(<br>
{<br>
marginsType: 0,<br>
printBackground: false,<br>
printSelectionOnly: false,<br>
landscape: false<br>
},<br>
function(error1, data1) {<br>
fs.writeFile(rootDir + "/UI/Temp/print.pdf", (data1, error1) =&gt; {<br>
resolve("Success");<br>
});<br>
}<br>
);<br>
}<br>
});</p>
<p dir="auto">return out;<br>
}</p>
<h3 dir="auto">Additional Information</h3>
<h1 dir="auto">CALL STACK</h1>
<p dir="auto">WebContents.printToPDF (c:\BucksWild\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:218)<br>
dataOut (c:\BucksWild\main.js:310)<br>
global.PrintToPDF (c:\BucksWild\main.js:308)<br>
ExecuteBackendFx (c:\BucksWild\IPCEVENTS.js:131)<br>
InitializeEvents.ipc.on (c:\BucksWild\IPCEVENTS.js:157)<br>
emit (events.js:182)<br>
(anonymous function) (c:\BucksWild\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:355)<br>
emit (events.js:182)</p>
<p dir="auto">Unable to open 'web-contents.js': File not found (file:///c:/BucksWild/node_modules/electron/dist/resources/electron.asar/browser/api/web-contents.js).</p>
<p dir="auto">It prints normally when the request comes from the backend directly.for eg calling the function directly from the debug on VSCODE</p>