I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0. Thank you in advance :)
For HTML output, you should now use Jupyter in place of IPython and select File -> Download as -> HTML (.html) or run the following command:
jupyter nbconvert --to html notebook.ipynb
This will convert the Jupyter document file notebook.ipynb into the html output format.
Google Colaboratory is Google's free Jupyter notebook environment that requires no setup and runs entirely in the cloud. If you are using Google Colab the commands are the same, but Google Colab only lets you download .ipynb or .py formats.
Convert the html file notebook.html into a pdf file called notebook.pdf. In Windows, Mac or Linux, install wkhtmltopdf. wkhtmltopdf is a command line utility to convert html to pdf using WebKit. You can download wkhtmltopdf from the linked webpage, or in many Linux distros it can be found in their repositories.
wkhtmltopdf notebook.html notebook.pdf
Original (now almost obsolete) revision:
Convert the IPython notebook file to html.
ipython nbconvert --to html notebook.ipynb
This will convert the IPython document file notebook.ipynb into the html output format.
Convert the html file notebook.html into a pdf file called notebook.pdf. In Windows, Mac or Linux, install wkhtmltopdf. wkhtmltopdf is a command line utility to convert html to pdf using WebKit. You can download wkhtmltopdf from the linked webpage, or in many Linux distros it can be found in their repositories.
wkhtmltopdf notebook.html notebook.pdf
I was facing the same problem. I tried to use the option select File --> Download as --> Pdf via LaTeX (.pdf) in the notebook but it did not worked for me(It is not working for me). I tried other options too still not working.
I solved it by using the following very simple steps. I hope it will help you too:
You can do it by 1st converting the notebook into HTML and then into PDF format:
Following steps I have implemented on: OS: Ubuntu, Anaconda-Jupyter notebook, Python 3
Start the jupyter notebook that you want to save in HTML format. First save the notebook properly so that HTML file will have a latest saved version of your code/notebook.
Run the following command from the notebook itself:
!jupyter nbconvert --to html notebook_name.ipynb
After execution will create HTML version of your notebook and will save it in the current working directory. You will see one html file will be added into the current directory with your_notebook_name.html name
(notebook_name.ipynb --> notebook_name.html).
notebook_name.html file (click on it). It will be opened in a new tab of your browser.Note that from print option we also have the flexibility of selecting a portion of a notebook to save in pdf format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With