Skip to content

Commit 2dc4297

Browse files
trop[bot]zcbenz
authored andcommitted
docs: update webContents.printToPDF() example for promisified API (electron#21550)
References: electron#16795 electron#17907
1 parent 577d048 commit 2dc4297

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/api/web-contents.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,12 +1323,13 @@ win.loadURL('http://github.com')
13231323

13241324
win.webContents.on('did-finish-load', () => {
13251325
// Use default printing options
1326-
win.webContents.printToPDF({}, (error, data) => {
1327-
if (error) throw error
1326+
win.webContents.printToPDF({}).then(data => {
13281327
fs.writeFile('/tmp/print.pdf', data, (error) => {
13291328
if (error) throw error
13301329
console.log('Write PDF successfully.')
13311330
})
1331+
}).catch(error => {
1332+
console.log(error)
13321333
})
13331334
})
13341335
```

0 commit comments

Comments
 (0)