From b57d21846613e267ed9b2d1c9adaac996e33d5d4 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Mon, 16 Dec 2019 19:14:13 -0500 Subject: [PATCH] docs: update webContents.printToPDF() example for promisified API (#21541) --- docs/api/web-contents.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 000396cb3a2a..a90c55908166 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1318,12 +1318,13 @@ win.loadURL('http://github.com') win.webContents.on('did-finish-load', () => { // Use default printing options - win.webContents.printToPDF({}, (error, data) => { - if (error) throw error + 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) }) }) ```