Quantcast
Channel: Electron: print iframe given reference to it - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Electron: print iframe given reference to it

$
0
0

I would like to use the react-to-print library to print an iframe from my Electron app. How can I use the iframe reference to get the correct window/element to print?

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="printWindow", 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) => {    if (!success) console.log(failureReason);    console.log('Print Initiated');  }); };<ReactToPrint ... print={handleElectronPrint}/>

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>