0

How to convert Jupyter notebook to pdf, only obtaining the markdown cells and output?

I am having difficulty using Jupyter nbconvert to export my Jupyter notebook to a pdf. I would like the pdf to show my markdown cells and the output of the cells but NOT the code. For the purpose of this question the name of my notebook is Deskbook.ipynb. I have been trying these commands from the same working directory of the notebook.

I have attempted this in the notebook itself, as follows:

!ipython nbconvert --to pdf --no-input Deskbook.ipynb

and the error I receive is

ipython: error: unrecognized arguments: --no-input Deskbook.ipynb

I have also tried the following on a Mac terminal

% $jupyter nbconvert --to pdf --no-input Deskbook.ipynb

and the error I receive is

zsh: command not found: nbconvert

I have also tried the same command in the the Jupyter notebook, python shell (through Terminal on Mac and AnacondaPrompt.exe on my Windows 10 Thinkpad), and receive the following error:

 $jupyter nbconvert --to pdf --no-input 'Deskbook.ipynb'
    ^
SyntaxError: invalid syntax

Ideally, I would like to add the functionality of converting to pdfs in a cell at the end of the notebook. The reason I am doing this is to share the output of my notebook (Figures and html rendered Pandas dataframes) with people who do not code. I have also tried to download using the drop down menu in Jupyter, and while PDF via latex does work, my tables are all scrambled in the file. I have seen a variety of answers about this on stack overflow, but none seem to be working for me. I have access to both a Windows 10 and Mac OS Big Sur setup

desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Hey! You may also wish to take a look at [this question](https://stackoverflow.com/questions/34818723/export-notebook-to-pdf-without-code) which seems to have a similar premise – Joel Lee Jun 28 '22 at 05:04
  • You can try to use the [Mercury](https://github.com/mljar/mercury) framework for [sharing notebooks with non-programmers](https://mljar.com/blog/share-jupyter-notebook/). You can easily hide the code and share the notebook as a web app or export it to PDF. You can [schedule automated execution of notebooks](https://mljar.com/blog/automated-reports-python/) and send notebook PDFs by email. – pplonski Jul 11 '22 at 11:56

0 Answers0