Did anyone worked on electron.js pdf export? I need to export the file to pdf while clicking on button and i used ".webContents.printToPDF" but "'did-finish-load'" is not working for me.
electron version - 16 node version - 14
electron.ipcMain.on('exportPdf', (event, path) => {
console.log("data-above000");
// Use default printing options
console.log("data-above");
// const pdfPath = ph.join(__dirname, 'docs/new.pdf');
mainWindow.webContents.printToPDF(options).then(data => {
console.log("data", data);
fs.writeFile(path, data, (error) => {
if (error) throw error
console.log(`Wrote PDF successfully to ${path}`)
})
}).catch(error => {
console.log(`Failed to write PDF to ${path}: `, error)
})
console.log("data-below");
})