Avoid Undefined Variable In printToPdf Example (#31465)

Co-authored-by: universalstrapping <90921972+universalstrapping@users.noreply.github.com>
This commit is contained in:
trop[bot]
2021-10-19 17:41:24 +09:00
committed by GitHub
parent 79554ba989
commit cd8f678a8d

View File

@@ -1494,8 +1494,8 @@ win.loadURL('http://github.com')
win.webContents.on('did-finish-load', () => {
// Use default printing options
const pdfPath = path.join(os.homedir(), 'Desktop', 'temp.pdf')
win.webContents.printToPDF({}).then(data => {
const pdfPath = path.join(os.homedir(), 'Desktop', 'temp.pdf')
fs.writeFile(pdfPath, data, (error) => {
if (error) throw error
console.log(`Wrote PDF successfully to ${pdfPath}`)