docs: update webContents.printToPDF() example for promisified API (#21541)

This commit is contained in:
Javan Makhmali 2019-12-16 19:14:13 -05:00 committed by Shelley Vohr
parent 9c442e0a7e
commit b57d218466

View file

@ -1318,12 +1318,13 @@ win.loadURL('http://github.com')
win.webContents.on('did-finish-load', () => { win.webContents.on('did-finish-load', () => {
// Use default printing options // Use default printing options
win.webContents.printToPDF({}, (error, data) => { win.webContents.printToPDF({}).then(data => {
if (error) throw error
fs.writeFile('/tmp/print.pdf', data, (error) => { fs.writeFile('/tmp/print.pdf', data, (error) => {
if (error) throw error if (error) throw error
console.log('Write PDF successfully.') console.log('Write PDF successfully.')
}) })
}).catch(error => {
console.log(error)
}) })
}) })
``` ```