feat(pdf): allow changing page size via attribute

This commit is contained in:
Elian Doran 2025-02-01 17:10:49 +02:00
parent 9a3a6f90ea
commit f41138800f
No known key found for this signature in database
2 changed files with 3 additions and 0 deletions

View File

@ -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")
});
}

View File

@ -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,