mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
feat(pdf): error handling
This commit is contained in:
parent
d4965e8d41
commit
84532d42ec
@ -71,11 +71,20 @@ ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Report if there is an error in generating the PDF.
|
||||
const buffer = await browserWindow.webContents.printToPDF({});
|
||||
let buffer: Buffer;
|
||||
try {
|
||||
buffer = await browserWindow.webContents.printToPDF({});
|
||||
} catch (e) {
|
||||
dialog.showErrorBox(t("pdf.unable-to-export-title"), t("pdf.unable-to-export-message"));
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Report if there was an error in saving the PDF.
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
try {
|
||||
fs.writeFileSync(filePath, buffer);
|
||||
} catch (e) {
|
||||
dialog.showErrorBox(t("pdf.unable-to-export-title"), t("pdf.unable-to-save-message"));
|
||||
return;
|
||||
}
|
||||
|
||||
shell.openPath(filePath);
|
||||
});
|
||||
|
@ -255,6 +255,9 @@
|
||||
"note-cannot-be-displayed": "This note type cannot be displayed."
|
||||
},
|
||||
"pdf": {
|
||||
"export_filter": "PDF Document (*.pdf)"
|
||||
"export_filter": "PDF Document (*.pdf)",
|
||||
"unable-to-export-message": "The current note could not be exported as a PDF.",
|
||||
"unable-to-export-title": "Unable to export as PDF",
|
||||
"unable-to-save-message": "The selected file could not be written to. Try again or select another destination."
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user