To convert a '.ipynb' Jupyter Notebook file into PDF, it should be intially be converted into a HTML file and then be converted into a pdf file for better representation.
- Install "nbconvert" tool through pip.
pip install nbconvert
Note:- If you have installed Anaconda and you are running the above command on cmd (Windows Terminal) then nbconvert will only be accessable to applications using cmd flow. So, please run the above command even on Anaconda Prompt.
- Download the "wkhtmltopdf" library/tool to convert the '.html' file to '.pdf' : - HERE
- Install the "pdfkit" library through the following command
pip install pdfkit
Mechanism:- JupyterNotebook --> HTML --> PDF
- Convert Jupyter Notebook to HTML file. In the below command mention the complete path of your jupyter notebook (Example: jupyter nbconvert --to html C:\Users\niran\Desktop\ipynb_to_pdf\mynotebook.ipynb).
- Perform the below operation in Jupyter Terminal.
jupyter nbconvert --to html Yournotebook.ipynb
Jupyter Terminal can be found here:-
- Further convert the HTML file into PDF file through the PDF_Converter.py file.
Note: - Go through the PDF_Converter.py file keenly.