How to convert IPYNB to PDF?

Jupyter Notebook or Google Collab basically supports .ipynb’s, i.e. Python NoteBook. These NoteBooks provide accessibility to the interactive Python code consisting of cell structures.
However, this .ipynb can be directly downloaded into the system or uploaded to your cloud as .ipynb. But if you are looking at how to convert ipynb to PDF, we are here with 4 easy and simple methods to convert ipynb to PDF. Let’s start.

First Method

Open your notebook and under the menu options, look for File, click Download as and look for .pdf via Latex. Remember, there will be two PDF options available, but the final extension of the downloaded file is stated in round braces beside the available options. So here, click for (.pdf) as shown below.

converting IPYNB to PDF using jupyter via latex

Next, the new tab will be opened in your browser for further processing

If you are downloading pdf for the first time from this option, there will be a lot of packages it will ask you to install, starting from this:

click on install

Install all of them, it may take 4-5 mins.

After installation, the terminal will have a success message like this:

cmd message of success

Right after the message, your pdf will be downloaded through your notebook tab.

ipynb converted to pdf successfully

Second Method

Here, we are downloading the pdf with nbconvert.
nbconvert is a command line tool.

Type in your cmd,

pip install nbconvert

This command will check if your system has nbconvert, if it hasn’t, the command will anyways download it.

And the following command will simply convert your ipynb to pdf.

jupyter nbconvert --to pdf filename.ipynb

The file’s location will be the same folder as your notebook.

Note: If you want to convert the notebook to .html, to make it available offline, you can run the same command, just replace pdf with html as,

jupyter nbconvert --to html filename.ipynb

Third Method

Another smart way to convert IPYNB to PDF is to print the notebook and when the printing interface opens, simply save it as PDF.

This is a straightforward and smart way to convert IPYNB to PDF.

click on print preview in jupyter

Follow the path, File->Print Preview, and preview to file

Now press Ctrl+P.

The printing interface will open up. If the printer is selected already, from the same dropdown, select Save as PDF.

Your PDF is ready.

However, if we compare PDFs with Save as PDF and through the notebook’s functions, both are readable, but one with Jupyter’s functions is slightly more zoomed and like a proper paper with filename and last modified date.

Fourth Method

It’s very easy, open your browser, search google colab, click on the first link, upload your ipynb file, click on the file, then click on print. Click here to directly open google colab.

This method is the easiest one but the problem is that pdf generated will not look similar to the ipynb file.

Thank you, we have successfully completed all methods to convert ipynb to pdf.

Also Read:

Avatar of Ayush Jha

Author: Ayush Jha