From a78affdd362e6228c748adcc403aacef71ccdfc4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 23:07:43 +0000 Subject: [PATCH] fix: contents.printToPDF option plumbing Co-authored-by: Shelley Vohr --- lib/browser/api/web-contents.ts | 14 +++++++------- shell/browser/api/electron_api_web_contents.cc | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 5b9131fcec003..1890bdb018509 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -173,13 +173,13 @@ WebContents.prototype.printToPDF = async function (options) { headerTemplate: '', footerTemplate: '', printBackground: false, - scale: 1, + scale: 1.0, paperWidth: 8.5, - paperHeight: 11, - marginTop: 0, - marginBottom: 0, - marginLeft: 0, - marginRight: 0, + paperHeight: 11.0, + marginTop: 0.0, + marginBottom: 0.0, + marginLeft: 0.0, + marginRight: 0.0, pageRanges: '', preferCSSPageSize: false }; @@ -209,7 +209,7 @@ WebContents.prototype.printToPDF = async function (options) { if (typeof options.scale !== 'number') { return Promise.reject(new Error('scale must be a Number')); } - printSettings.scaleFactor = options.scale; + printSettings.scale = options.scale; } const { pageSize } = options; diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index ec6a24301111c..e12bc087c693f 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -2821,12 +2821,12 @@ v8::Local WebContents::PrintToPDF(const base::Value& settings) { settings.GetDict().FindBool("displayHeaderFooter"); auto print_background = settings.GetDict().FindBool("shouldPrintBackgrounds"); auto scale = settings.GetDict().FindDouble("scale"); - auto paper_width = settings.GetDict().FindInt("paperWidth"); - auto paper_height = settings.GetDict().FindInt("paperHeight"); - auto margin_top = settings.GetDict().FindIntByDottedPath("margins.top"); - auto margin_bottom = settings.GetDict().FindIntByDottedPath("margins.bottom"); - auto margin_left = settings.GetDict().FindIntByDottedPath("margins.left"); - auto margin_right = settings.GetDict().FindIntByDottedPath("margins.right"); + auto paper_width = settings.GetDict().FindDouble("paperWidth"); + auto paper_height = settings.GetDict().FindDouble("paperHeight"); + auto margin_top = settings.GetDict().FindDouble("marginTop"); + auto margin_bottom = settings.GetDict().FindDouble("marginBottom"); + auto margin_left = settings.GetDict().FindDouble("marginLeft"); + auto margin_right = settings.GetDict().FindDouble("marginRight"); auto page_ranges = *settings.GetDict().FindString("pageRanges"); auto header_template = *settings.GetDict().FindString("headerTemplate"); auto footer_template = *settings.GetDict().FindString("footerTemplate");