mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Report if there is an error in generating the PDF.
|
let buffer: Buffer;
|
||||||
const buffer = await browserWindow.webContents.printToPDF({});
|
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.
|
try {
|
||||||
fs.writeFileSync(filePath, buffer);
|
fs.writeFileSync(filePath, buffer);
|
||||||
|
} catch (e) {
|
||||||
|
dialog.showErrorBox(t("pdf.unable-to-export-title"), t("pdf.unable-to-save-message"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
shell.openPath(filePath);
|
shell.openPath(filePath);
|
||||||
});
|
});
|
||||||
|
@ -255,6 +255,9 @@
|
|||||||
"note-cannot-be-displayed": "This note type cannot be displayed."
|
"note-cannot-be-displayed": "This note type cannot be displayed."
|
||||||
},
|
},
|
||||||
"pdf": {
|
"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