Search code examples
python-3.xpdfjupyter-notebooknbconvert

Convert Jupyter notebook to PDF with nbconvert. Want the output to look exactly like the jupyter notebook


I use Jupyter notebook for Python in a project at school. I want to convert the notebook to a PDF file. I installed nbconvert and made it work. Only problem is that I want the pdf to look exactly like the notebook itself, ie include the borders around the input and output cells. When I used markdown in cells to comment my work the spacing also was wrong. Works great when I convert to html, but I need a pdf.

tl;dr: I want the PDF file to include the borders around the cells.


Solution

  • Try using template system of nbconvert.

    There is already a template that you can use https://github.com/t-makaro/nb_pdf_template

    You should get something like this enter image description here

    Installation

    pip install nb_pdf_template
    python -m nb_pdf_template.install
    

    Usage

    jupyter nbconvert --to pdf filename.ipynb --template classic