Skip to content

Instantly share code, notes, and snippets.

@MohamedElashri
Created August 27, 2021 14:58
Show Gist options
  • Save MohamedElashri/a52df7adcd8873a4004ada64b462f038 to your computer and use it in GitHub Desktop.
Save MohamedElashri/a52df7adcd8873a4004ada64b462f038 to your computer and use it in GitHub Desktop.
This is documentation on how to convert jupyter notebook to pdf

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/example.ipynb ./

Then you can run the converter.

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

Then you can download the file in the left side panel or through running this cell

from google.colab import files
files.download('example.pdf') 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment