title: Electron: print iframe given reference to it
body: <p>I would like to use the <a href="https://www.npmjs.com/package/react-to-print" rel="noreferrer"><code>react-to-print</code></a> library to print an <code>iframe</code> from my Electron app. How can I use the <code>iframe</code> reference to get the correct window/element to print?</p>
  <pre><code>const handleElectronPrint = async (target: HTMLIFrameElement) {
    // Instead of this (printing the whole page)
    // let win = BrowserWindow.getFocusedWindow();
  
    // How do I print just the referenced iframe?
    // `target` iframe has id=&quot;printWindow&quot;, how to select it?
    let win = BrowserWindow.getMyIframe();
    
    // Is this the right way to do the print once we have the iframe?
    const options = { printBackground: true };
    win.webContents.print(options, (success, failureReason) =&gt; {
      if (!success) console.log(failureReason);
    
      console.log('Print Initiated');
    }); 
  };
  
  &lt;ReactToPrint
   ...
   print={handleElectronPrint}
  /&gt;
  </code></pre>