Avoid Undefined Variable In printToPdf Example (#31455)

This commit is contained in:
universalstrapping 2021-10-18 20:53:59 -04:00 committed by GitHub
parent 6f31683ea5
commit 14736c5f30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1485,8 +1485,8 @@ 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({}).then(data => {
const pdfPath = path.join(os.homedir(), 'Desktop', 'temp.pdf') const pdfPath = path.join(os.homedir(), 'Desktop', 'temp.pdf')
win.webContents.printToPDF({}).then(data => {
fs.writeFile(pdfPath, data, (error) => { fs.writeFile(pdfPath, data, (error) => {
if (error) throw error if (error) throw error
console.log(`Wrote PDF successfully to ${pdfPath}`) console.log(`Wrote PDF successfully to ${pdfPath}`)