Skip to content
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

Handle printing of documents in browser #1314

blink1073 opened this issue Nov 28, 2016 · 2 comments

Handle printing of documents in browser #1314

blink1073 opened this issue Nov 28, 2016 · 2 comments


Copy link

@blink1073 blink1073 commented Nov 28, 2016

So you can hit the browser's print button and get a nice looking printout. This should take into account the most recent document.

Copy link

@jasongrout jasongrout commented Nov 28, 2016

Background on the print media selector -

If there is a CSS class applied to the currently active document, we could maybe do something like @media print .document:not(.active-document) {display: none} or something to hide everything except the current document. Interesting...

Copy link

@saulshanabrook saulshanabrook commented Nov 29, 2018

I investigated the above solution and couldn't get it to work. Hiding not visible elements still leaves everything absolutely positioned by phosphor.

Then, I tried using creating an empty iframe, copying over the node we want to print into it, and calling print on the window. I used this library to do this:

That works for the JSON viewer, but doesn't work well for text editors or notebooks. For those, we need some custom functionality likely. For notebooks, we could use the To HTML functionality of nbconvert to get a nicer print preview.

So then we (@afshin @jasongrout) started talking about different ways widgets could provide custom print functionality. We settled on two ways do this that might be OK:

  1. Define a new Symbol for printing and have widgets that implement custom printing define a method named by the symbol.
  2. Send a message to the widget when printing. On the MainAreaWidget handle this method, and call the onPrintMessage method which subclasses define.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants