From f41138800f6fb425c88fd22fd9ab21a7f6878cda Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 1 Feb 2025 17:10:49 +0200 Subject: [PATCH] feat(pdf): allow changing page size via attribute --- src/public/app/widgets/note_detail.js | 1 + src/services/window.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 21f84dbc1..11cc6f71d 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -261,6 +261,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { const { ipcRenderer } = utils.dynamicRequire("electron"); ipcRenderer.send("export-as-pdf", { title: this.note.title, + pageSize: this.note.getAttributeValue("label", "pageSize") ?? "Letter", landscape: this.note.hasAttribute("label", "printLandscape") }); } diff --git a/src/services/window.ts b/src/services/window.ts index ff391875b..8c3fd9118 100644 --- a/src/services/window.ts +++ b/src/services/window.ts @@ -51,6 +51,7 @@ ipcMain.on("create-extra-window", (event, arg) => { interface ExportAsPdfOpts { title: string; landscape: boolean; + pageSize: "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "Legal" | "Letter" | "Tabloid" | "Ledger"; } ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => { @@ -76,6 +77,7 @@ ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => { try { buffer = await browserWindow.webContents.printToPDF({ landscape: opts.landscape, + pageSize: opts.pageSize, generateDocumentOutline: true, generateTaggedPDF: true, displayHeaderFooter: true,