In this article, you’ll learn how to Convert IPython to PDF using Python.
- There is an easy way to turn our Jupyer Notebooks into PDF files.
- Just with a simple setup, you can access your notebook as a PDF.
- Python Basics
- -U notebook-as-pdf Basics
- pyppeteer-install module
Install Necessary Modules:
Once Installed now we can import it inside our python code.
- The first thing we need to do is to install the necessary package. Here we would use the package called notebook-as-pdf to help us convert Jupyter Notebook as PDF file. You need to run the following code in your command prompt. If you are using Anaconda type in anaconda command prompt.
- We also need an additional setup for Chromium. It is used to perform the HTML to PDF conversion. Just run the following code in your code prompt. If you are using Anaconda type in anaconda command prompt.
- Just like that, we have already finished our preparation. Now, let’s open the notebook you intend to convert into the PDF. In your notebook, click the File menu bar then select Download as then select the PDF via HTML (.pdf) to transform the notebook.
- (optional) Just like that, you already have your notebook as a PDF file. If you prefer to use command prompt to convert the notebook, you could do it with the following code.
jupyter-nbconvert --to PDFviaHTML example.ipynbCode language: CSS (css)
The result would be called example.pdf as our Jupyter Notebook is called example.ipynb.