Skip to content

Commit

Permalink
Merge pull request #827 from frappe/fix_electron_printpdf_bug
Browse files Browse the repository at this point in the history
Fixing printToPDF from electron window
  • Loading branch information
Isaac-GC authored Feb 1, 2024
2 parents 9aa2046 + 91f2a13 commit 641ffac
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions main/saveHtmlAsPdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 641ffac

Please sign in to comment.