diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index f93e74fbc6ad7..c608f44708eda 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1323,12 +1323,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) }) }) ```