-
-
Notifications
You must be signed in to change notification settings - Fork 43
plotly-graph PDF with electron's printToPDF #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
090b200
add util/remote + mucho plotly-dashboard tests
etpinard 54b4173
add printToPDF renderer logic for plotly-graph
etpinard 406b920
pass 'scale' to Plotly.toImage
etpinard f69172b
rewrite batik util
etpinard b2b3ea3
add pdftops util (to convert pdf2eps)
etpinard b90d7fc
add pretest script
etpinard 828d2a3
scale PDF pageSize in render
etpinard 1c9193e
update plotly-graph convert with new batik + pdftops logic
etpinard f104ad3
Merge branch 'master' into plotly-graph-pdf
etpinard 5992a8b
improve printToPDF page size logic
etpinard 135cb1b
new format=pdf strategy:
etpinard 649f97f
put pdf page image load timeout value in constants.js
etpinard 23cfc95
add plotGlPixelRatio to improve look of gl3d grid lines
etpinard acb007b
fixup tests
etpinard 96b1fbc
:hocho: batik as `printToPDF` :trophy:
etpinard f8708a2
add test convert + Pdftops instance test
etpinard 11b67c3
add circleci 2.0 config
etpinard 47614f9
:books:
etpinard f93bd57
rm unnecessary else branch
etpinard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no fi 8000 les selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
iframeLoadDelay: 5000, | ||
|
||
statusMsg: { | ||
525: 'print to PDF error' | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* Small wrapper around the renderer process 'remote' module, to | ||
* easily mock it using sinon in test/common.js | ||
* | ||
* More info on the remote module: | ||
* - https://electron.atom.io/docs/api/remote/ | ||
*/ | ||
|
||
function load () { | ||
return require('electron').remote | ||
} | ||
|
||
module.exports = { | ||
createBrowserWindow: (opts) => { | ||
const _module = load() | ||
return new _module.BrowserWindow(opts) | ||
}, | ||
getCurrentWindow: () => load().getCurrentWindow() | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the f
A78C
ile in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageSize
here expects numbers in micrometer, plotly.js set width and height in pixels. I took this number from this source. I gives ok results, but not perfect.Comparing the batik and electron outputs of a graph with non-white bg illustrates the issue:
batik on the left /
printToPDF
on the right.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 5992a8b improves this.
But
printToPDF
still output a (small white) margin:Would this be a deal-breaker for
printToPDF
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with 135cb1b
those white margins are gone (actually, they're still there, but now they appear with
background-color: fullLayout.paper_bgcolor
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the deep dive into this one @etpinard - given all the other improvements we get with
printToPDF
I think this extra bit of margin, now that it keeps the right color, is acceptable.Might be worthwhile at some point taking another look at this but for the first release this is great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure. I'll open an issue as soon as this PR is merged.