Google Co-laboratory notebook PDF download
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:
- 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
- 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
- Download .ipynb file
- Download as html
- Print PDF from browser
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on October 06, 2022Comments
-
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?