Jupyter Notebook + R: save to pdf without code

625 views
Skip to first unread message

jclau

unread,
Jul 29, 2018, 8:00:47 PM7/29/18
to Project Jupyter
Hi there,

I would like to export a Jupyter notebook containing Markdown + R code + outputs with just Markdown + outputs. I've been following a solution posted on StackOverflow where they suggest setting the "--TemplateExporter.exclude_input" flag: https://stackoverflow.com/questions/49754862/jupyter-notebook-save-to-pdf-without-code

The following solution works as expected when exporting to html:
$ jupyter nbconvert volume_stats.ipynb --to=html --TemplateExporter.exclude_input=True
[NbConvertApp] Converting notebook volume_stats.ipynb to html
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nbconvert/filters/datatypefilter.py:41: UserWarning: Your element with mimetype(s) [] is not able to be represented.
  mimetypes=output.keys())
[NbConvertApp] Writing 907954 bytes to volume_stats.html

However, switching the export to pdf does not work:
$ jupyter nbconvert volume_stats.ipynb --to=pdf --TemplateExporter.exclude_input=True
[NbConvertApp] Converting notebook volume_stats.ipynb to pdf
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nbconvert/filters/datatypefilter.py:41: UserWarning: Your element with mimetype(s) [] is not able to be represented.
  mimetypes=output.keys())
[NbConvertApp] Support files will be in volume_stats_files/
[NbConvertApp] Making directory volume_stats_files
[NbConvertApp] Making directory volume_stats_files
[NbConvertApp] Making directory volume_stats_files
[NbConvertApp] Making directory volume_stats_files
[NbConvertApp] Making directory volume_stats_files
[NbConvertApp] Making directory volume_stats_files
[NbConvertApp] Writing 35763 bytes to notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: [u'xelatex', u'notebook.tex']
[NbConvertApp] Running bibtex 1 time: [u'bibtex', u'notebook']
[NbConvertApp] WARNING | bibtex had problems, most likely because there were no citations
[NbConvertApp] PDF successfully created
[NbConvertApp] Writing 366844 bytes to volume_stats.pdf

Version info:
Server Information:
You are using Jupyter notebook.
The version of the notebook server is: 5.5.0
The server is running on this version of Python:
Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Current Kernel Information:
R version 3.4.3 (2017-11-30)

Fyi, I've cross-posted this as an issue on github: https://github.com/jupyter/notebook/issues/3804. Appreciate the help,
j

jclau

unread,
Aug 6, 2018, 9:10:14 PM8/6/18
to Project Jupyter
Hi there,

Fyi, for now I've found a temporary workaround involving converting the ipynb files to html first and then printing the output html document to pdf.

Any guidance on this would be appreciated,
j
Reply all
Reply to author
Forward
0 new messages