From 91f2a130c782bdd2412259df9c8761faf46d3a82 Mon Sep 17 00:00:00 2001 From: Isaac GC Date: Mon, 29 Jan 2024 19:13:14 -0800 Subject: [PATCH] Fixing printToPDF from electron window --- main/saveHtmlAsPdf.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/main/saveHtmlAsPdf.ts b/main/saveHtmlAsPdf.ts index 93514d3c4..81b08c88d 100644 --- a/main/saveHtmlAsPdf.ts +++ b/main/saveHtmlAsPdf.ts @@ -20,14 +20,12 @@ export async function saveHtmlAsPdf( const printWindow = await getInitializedPrintWindow(htmlPath, width, height); const printOptions = { - marginsType: 1, // no margin + margins: { top: 0, bottom: 0, left: 0, right: 0 }, // equivalent to previous 'marginType: 1' pageSize: { - height: height * 10_000, // micrometers - width: width * 10_000, // micrometers + height: height / 2.54, // Convert from centimeters to inches + width: width / 2.54, // Convert from centimeters to inches }, printBackground: true, - printBackgrounds: true, - printSelectionOnly: false, }; const data = await printWindow.webContents.printToPDF(printOptions);