mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-31 04:02:26 +08:00
feat(pdf): allow changing page size via attribute
This commit is contained in:
parent
9a3a6f90ea
commit
f41138800f
@ -261,6 +261,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
const { ipcRenderer } = utils.dynamicRequire("electron");
|
const { ipcRenderer } = utils.dynamicRequire("electron");
|
||||||
ipcRenderer.send("export-as-pdf", {
|
ipcRenderer.send("export-as-pdf", {
|
||||||
title: this.note.title,
|
title: this.note.title,
|
||||||
|
pageSize: this.note.getAttributeValue("label", "pageSize") ?? "Letter",
|
||||||
landscape: this.note.hasAttribute("label", "printLandscape")
|
landscape: this.note.hasAttribute("label", "printLandscape")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ ipcMain.on("create-extra-window", (event, arg) => {
|
|||||||
interface ExportAsPdfOpts {
|
interface ExportAsPdfOpts {
|
||||||
title: string;
|
title: string;
|
||||||
landscape: boolean;
|
landscape: boolean;
|
||||||
|
pageSize: "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "Legal" | "Letter" | "Tabloid" | "Ledger";
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => {
|
ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => {
|
||||||
@ -76,6 +77,7 @@ ipcMain.on("export-as-pdf", async (e, opts: ExportAsPdfOpts) => {
|
|||||||
try {
|
try {
|
||||||
buffer = await browserWindow.webContents.printToPDF({
|
buffer = await browserWindow.webContents.printToPDF({
|
||||||
landscape: opts.landscape,
|
landscape: opts.landscape,
|
||||||
|
pageSize: opts.pageSize,
|
||||||
generateDocumentOutline: true,
|
generateDocumentOutline: true,
|
||||||
generateTaggedPDF: true,
|
generateTaggedPDF: true,
|
||||||
displayHeaderFooter: true,
|
displayHeaderFooter: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user