feat(pdf): support landscape mode at note level

This commit is contained in:
Elian Doran 2025-02-01 00:28:48 +02:00
parent 658ce103fc
commit f3a3906db7
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View File

@ -299,7 +299,8 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
const { ipcRenderer } = utils.dynamicRequire("electron");
ipcRenderer.send("export-as-pdf", {
title: this.note.title
title: this.note.title,
landscape: this.note.hasAttribute("label", "printLandscape")
});
}

View File

@ -50,6 +50,7 @@ ipcMain.on("create-extra-window", (event, arg) => {
interface ExportAsPdfOpts {
title: string;
landscape: boolean;
}
ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => {
@ -73,7 +74,9 @@ ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => {
let buffer: Buffer;
try {
buffer = await browserWindow.webContents.printToPDF({});
buffer = await browserWindow.webContents.printToPDF({
landscape: opts.landscape
});
} catch (e) {
dialog.showErrorBox(t("pdf.unable-to-export-title"), t("pdf.unable-to-export-message"));
return;