I have a nicely-formatted ipython notebook complete with markdown cells and whatnot. I'm wondering what my options are in terms of exporting to a PDF file.
So far, I've been going to File > Print View
and printing the resulting page to PDF with chromium's "save to file" function. This technically works, but it has one major inconvenience: my figures, code and markdown cells are often split by page breaks.
Are there any other solutions for explort such that I can have one continuous PDF file?
EDIT: I ran into nbconvert, but when I keep getting a "file not found" error. Anybody have any luck with nbconvert? The documentation claims to support exporting to PDF, but when I ran nbconvert.py -f pdf
, the error message suggested that the PDF format was not, in fact, supported.
you cannot directly convert an ipynb into a pdf, so the error message is right!
You need to first convert it into latex: nbconvert.py -f latex your_nb.ipynb
and then use pdflatex your_nb.tex
to build the pdf file.
Hope it helps.
You can use ipython to do this, for instance the command:
ipython nbconvert notebookname.ipynb --to latex --post pdf
to convert notebookname.ipynb to a pdf. It does however require that you are running the latest version of texlive (that's texlive 2013) to have the supporting software. Note that Ubuntu 12.04 comes with texlive 2009 from their repositories. 2013 can be installed from CTAN directly, just follow these directions. Then you are up and running, and it looks great.
IF all else fails as tex can be quite moody... install wkhtmltopdf
\i then use nbconvert to create a html, and then wkhtmltopdf to create the pdf.
If you're converting notebooks often enough, here is a script that uses wkhtmltopdf to convert a selected notebook into HTML and PDF. Once you've installed wkhtmltopdf, keep this script in the same folder as your notebooks and run it whenever you want to convert a notebook quickly.