Created
May 2, 2020 09:11
-
-
Save palashkulsh/1c10dc33c7b13ea6da7b1f518e60ec4e to your computer and use it in GitHub Desktop.
run this script after installing electron by electron index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { BrowserWindow,app } = require('electron') | |
const fs = require('fs') | |
app.on('ready', function (){ | |
let win = new BrowserWindow({ width: 800, height: 600 ,show:false}) | |
win.loadURL('https://fs.blog/2014/04/the-heart-of-humanity/') | |
win.webContents.on('did-finish-load', () => { | |
// Use default printing options | |
win.webContents.insertCSS('.section-suggested-reading {display: none !important;} footer.section-footer {display: none !important;} .sidebar {display: none !important;} .navigation {display: none !important;} .sumome-share-client, .sumome-share-client-mobile-bottom-bar, .sumome-share-client-counts, .sumome-share-client-light .sumome-share-client-medium {display: none !important;} .section-suggested-reading-wrapper {display: none !important;}') | |
win.webContents.printToPDF({}).then(data => { | |
fs.writeFile('/tmp/print.pdf', data, (error) => { | |
if (error) throw error | |
console.log('Write PDF successfully.') | |
}) | |
}).catch(error => { | |
console.log(error) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.