docs: update webContents.printToPDF() example for promisified API (#21541)
This commit is contained in:
parent
9c442e0a7e
commit
b57d218466
1 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue