Google Co-laboratory notebook PDF download

80,170

Solution 1

You can also run the solution of mayurmadnani directly on Colab.
Therefore create a new Python workbook in Colab and connect it to a runtime.
Install the necessary packages into the virtual machine with:

!apt-get install texlive texlive-xetex texlive-latex-extra pandoc
!pip install pypandoc

Mount your google drive to get access to your ipynb files

from google.colab import drive
drive.mount('/content/drive')

I had to copy the files from the drive to the working directory,
because the drive is/was mounted as read only.

!cp drive/My Drive/Colab Notebooks/Untitled.ipynb ./

Then you can run the converter.

!jupyter nbconvert --to PDF "Untitled.ipynb"

Then you can download the file in the left side panel.

Solution 2

Use the built-in browser print. Then, save the result as a pdf.

Solution 3

@user10914779's answer worked for me. But if you are looking for a shorter and readable code then you can take a look at this Github repo: colab-pdf.

You can paste the following code in the last cell of your colab notebook and run it. It will generate a PDF file and save it to your drive.

!wget -nc https://raw.githubusercontent.com/brpy/colab-pdf/master/colab_pdf.py
from colab_pdf import colab_pdf
colab_pdf('name-of-the-notebook.ipynb')

You can provide the name of the notebook to colab_pdf('name-of-the-notebook.ipynb'). If you are not interested in the output that this codeblock produces then you can hide it using '%%capture'

%%capture
!wget -nc https://raw.githubusercontent.com/brpy/colab-pdf/master/colab_pdf.py
from colab_pdf import colab_pdf

Solution 4

Try any one:

  1. You have an option File > Download .ipynb. Use below command to convert ipynb to pdf or any other format

jupyter nbconvert --to FORMAT notebook.ipynb

See usage guide: https://nbconvert.readthedocs.io/en/latest/usage.html

  1. As mentoned by Bob, use print option to save as pdf. Here, you may lose text if it goes out of the page

Solution 5

  1. Download .ipynb file
  2. Download as html
  3. Print PDF from browser
Share:
80,170
Admin
Author by

Admin

Updated on October 06, 2022

Comments

  • Admin
    Admin over 1 year

    Google Co-laboratory notebook doesn't have the "Download as" dropdown menu item in "File" menu like standalone Jupyter does. How to download the notebook as PDF?