12

Is there a way to print out a slide deck of a jupyter/ipython notebook slides? Is it possible to do from the nbviewer site (http://nbviewer.ipython.org) ?

I know that I can print a pdf of my notebook, but when I do, it doesn't have the same page breaks and doesn't skip all the code that I would like skipped (for example, the libraries I've imported aren't necessary). I'd like to have it as a backup or a printable handout.

cel
  • 30,017
  • 18
  • 97
  • 117
Anna S.
  • 153
  • 2
  • 7

1 Answers1

15

You can try this:

jupyter nbconvert --to slides --post serve /path/to/your/notebook.ipynb

This should fire up your browser and serve the presentation (e.g at http://127.0.0.1:8000/<some-title>.slides.html#/)

change the url to

 http://127.0.0.1:8000/<some-title>.slides.html?print-pdf

If you now open the print dialog from your browser, the slides should have the right formatting.

Instead of sending to a printer you should be able to choose to write to a pdf file from the printer menu.


I tested this in chrome on OSX. I assume it works on all systems, but I did not test.

cel
  • 30,017
  • 18
  • 97
  • 117
  • 1
    I tried this in Firefox on OSX and it worked for me. – Anna S. Dec 09 '15 at 18:42
  • @cel I like your solution. However, the text and graph is not at the expected location in pdf. I want the graph and the text explaining the graph to be in the same page. Is there a way to specify the content on each page of pdf, instead of letting the browser decide? – Lisa Aug 10 '16 at 21:34
  • @Lisa, When designing a slideshow you can use the slideshow toolbar `View->Cell Toolbar->Slideshow` to control what cells go on what page. The output pdf should respect your choices. – cel Aug 11 '16 at 05:22
  • How do you close it? I can't seem to Ctrl-C out of the process in shell. – François Leblanc Mar 28 '18 at 19:43