Last active
April 24, 2018 06:47
-
-
Save Samuell1/b0d8d9a8701b2ff0dbb84531d86667b9 to your computer and use it in GitHub Desktop.
ElectronJs
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
ipcMain.on('printPdf', (event, pdf) => { | |
printWindow = new BrowserWindow({width: 800, height: 600}) | |
printWindow.loadURL("data:text/html," + pdf) | |
printWindow.webContents.on("did-finish-load", function() { | |
// Use default printing options | |
printWindow.webContents.printToPDF({}, function(error, data) { | |
if (error) throw error | |
fs.writeFile(app.getPath('desktop') + '/test.pdf', data, function(err) { | |
if (err) | |
alert('write pdf file error', error) | |
}) | |
event.sender.send('printPdf-reply', true) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment