From 2a7d2e6371bbe04605006052f330cf7a2479ba54 Mon Sep 17 00:00:00 2001 From: tarzzz Date: Fri, 6 Sep 2019 17:37:33 -0400 Subject: [PATCH 1/3] Update pdfOptions.pageSize with pageSize defined in payload. --- src/component/plotly-dash-preview/parse.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/component/plotly-dash-preview/parse.js b/src/component/plotly-dash-preview/parse.js index 454ee64c..6aa18766 100644 --- a/src/component/plotly-dash-preview/parse.js +++ b/src/component/plotly-dash-preview/parse.js @@ -44,6 +44,10 @@ function parse (body, req, opts, sendToRenderer) { width: body.pageSize.width * cst.pixelsInMicron, height: body.pageSize.height * cst.pixelsInMicron } + result.pdfOptions.pageSize = { + width: body.pageSize.width, + height: body.pageSize.height + } } else { return errorOut( 400, From 76ac94ecfbebffee758b433493b533a3d0b89c26 Mon Sep 17 00:00:00 2001 From: tarzzz Date: Fri, 6 Sep 2019 17:39:03 -0400 Subject: [PATCH 2/3] Added test --- test/unit/plotly-dash-preview_test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/unit/plotly-dash-preview_test.js b/test/unit/plotly-dash-preview_test.js index 90230dd7..30756d25 100644 --- a/test/unit/plotly-dash-preview_test.js +++ b/test/unit/plotly-dash-preview_test.js @@ -54,6 +54,10 @@ tap.test('parse:', t => { height: 3.779527559055118, width: 3.779527559055118 }) + t.same(result.pdfOptions.pageSize, { + height: 1000, + width: 1000 + }) t.end() }) }) From 58e5930d9ff72b1ad7c78acddbf94c1ce0bc253f Mon Sep 17 00:00:00 2001 From: tarzzz Date: Fri, 6 Sep 2019 18:09:06 -0400 Subject: [PATCH 3/3] Change width/height to int. This is to prevent: https://github.com/electron/electron/issues/9361#issue-225991341 incase someone provides float values for width/height. --- src/component/plotly-dash-preview/parse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/component/plotly-dash-preview/parse.js b/src/component/plotly-dash-preview/parse.js index 6aa18766..83a62bf2 100644 --- a/src/component/plotly-dash-preview/parse.js +++ b/src/component/plotly-dash-preview/parse.js @@ -45,8 +45,8 @@ function parse (body, req, opts, sendToRenderer) { height: body.pageSize.height * cst.pixelsInMicron } result.pdfOptions.pageSize = { - width: body.pageSize.width, - height: body.pageSize.height + width: Math.ceil(body.pageSize.width), + height: Math.ceil(body.pageSize.height) } } else { return errorOut(