<p dir="auto">The problem occurs when pressing the button to print from the browser.<br>
The electron simply locks or ignores the pressure command.<br>
which load is any page like electron.com it prints normal.<br>
but when loading a pdf file and ordering the print it doesn't work.<br>
does this have any solution today?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const win2 = new BrowserWindow({
      webPreferences: {
        plugins: true
      }
    })

    win2.loadURL(__dirname + '/file.pdf', {})
    win2.webContents.once('did-finish-load', async function() {
      try {
        const pdfData = await win2.webContents.printToPDF({})
        const outPath = __dirname +'/snotas.pdf'
        fs.writeFile(outPath, pdfData, (error) =&gt; {
          if (error) throw error
          console.log(`Wrote PDF to: ${outPath}`)
        })
      } catch(e) {
        console.error(e)
      }

    })
  })"><pre class="notranslate"><code class="notranslate">const win2 = new BrowserWindow({
      webPreferences: {
        plugins: true
      }
    })

    win2.loadURL(__dirname + '/file.pdf', {})
    win2.webContents.once('did-finish-load', async function() {
      try {
        const pdfData = await win2.webContents.printToPDF({})
        const outPath = __dirname +'/snotas.pdf'
        fs.writeFile(outPath, pdfData, (error) =&gt; {
          if (error) throw error
          console.log(`Wrote PDF to: ${outPath}`)
        })
      } catch(e) {
        console.error(e)
      }

    })
  })
</code></pre></div>
<p dir="auto">The code above is only a third of the many I have tried.</p>
<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>9.1.0</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>macOS Mojave 10.14.6</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>just v9. Because in electron version 9 was introduce "pdf viewer", but now it cant print pdf.</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">just print correctly the pdf...</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">when you try to print with "window.print()" a page that load a PDF electron do not respond.... sometimes crash...</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">just clone "electron-quick-start" and replace this line :<br>
mainWindow.loadFile('index.html')<br>
for<br>
mainWindow.loadURL('<a href="http://www.africau.edu/images/default/sample.pdf" rel="nofollow">http://www.africau.edu/images/default/sample.pdf</a>')<br>
and replace all content script "preload.js" for:</p>
<p dir="auto">window.addEventListener('DOMContentLoaded', () =&gt; {<br>
window.print();<br>
});</p>
<p dir="auto">this is a example repo to reproduce the error:<br>
<a href="https://github.com/rgarcia1990/electron-quick-start">https://github.com/rgarcia1990/electron-quick-start</a></p>
<p dir="auto">just do the normal setup</p>
<p dir="auto">$ git clone <a href="https://github.com/rgarcia1990/electron-quick-start">https://github.com/rgarcia1990/electron-quick-start</a><br>
$ npm install<br>
$ npm start || electron .</p>
<p dir="auto">and when the app electron start will popup print dialog, just try to print!</p>
<p dir="auto">that is all!</p>