Convert (Jupyter Notebook) to
Convert (Jupyter Notebook) documents to format, edit and optimize documents online and free.
Convert IPYNB to PDF
Loading Uploader.
if you have uploaded a file, it will be displayed.
Confirm Cancel
Tags:
Jupyter Notebook (.ipynb)
An IPYNB file (Interactive Python Notebook) is a notebook document created by Jupyter Notebook, an interactive environment for students and scientists to analyze data using Python language. IPYNB files are usually converted to PDF, HTML, DOCX, RTF, and LaTeX formats.
Portable Document Fomat (.pdf)
PDF stands for Portable Document Format. It is a versatile file format created by Adobe in 1992 to present and exchange documents independent of software, hardware, and operating systems. It is now an open standard maintained by the International Organization for Standardization (ISO). PDFs can contain links, buttons, form fields, audio, video, and business logic and can be signed electronically. They can easily be viewed using the free Adobe Acrobat Reader software.
The 4 ways to export Jupyter Notebook as PDF

Have you ever wanted to export your Jupyter Notebook to PDF file? The PDF is an abbreviation for Portable Document Format. It can be displayed on any operating system. That makes it format of choice for many who wants to share their results. In this post I will show you 4 different ways how to export Jupyter Notebook as PDF file.
1. Print Jupyter Notebook to PDF
The most straightforward way is just to use web browser feature of print to PDF. There is no need to install any additional packages.
The big advantage of this approach is that we don’t need to install additional libraries to make it works! However, it is manual approach — hard to automate. What is more, we can’t control the process of export (for example, we can’t hide code in the exported file).
2. Download Jupyter Notebook as PDF
The Jupyter Notebook has an option to export the notebook to many formats. It can be accessed by clicking File -> Download as -> PDF via LaTeX (or PDF via HTML — not visible in the screenshot).

This approach requires you to install some additional packages. For me, the option that exports with LaTeX is difficult. It requires you to install much more packages than option of export via HTML. If you don’t have required packages you will get the error message:
nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.

This is scary, isn’t it? The option to export via HTML requires you to download Chromium (headless browser).
I rarely use this approach to be honest. It requires additional installation (that is not trivial) and is manual. This approach under the hood is using nbconvert tool.
3. Export to PDF with nbconvert
That’s one of my favourite approaches. Why? Because it is a command line tool that can be used in the scripts 🙂
Still you need to install additional packages to make it work. The same as in Jupyter Notebook GUI there are two options:
- export to PDF via LaTex,
- export to PDF via HTML.
The latter is my choice. It requires pyppeteer and Chromium to be download. This can be easily achieved by running:
pip install nbconvert[webpdf]
and adding a flag —allow-chromium-download when converting a notebook:
jupyter nbconvert --to webpdf --allow-chromium-download your-notebook-file.ipynb
The flag should be added only one time. It is not necessary after Chromium installation. The nbconvert has many optional arguments that control the export. For example, you can easily hide the code with —no-input flag:
jupyter nbconvert --to webpdf --no-input your-notebook-file.ipynb
Additionally, you can apply more options to the export like removing selected cells or change the templates.
4. Share Notebook with Mercury
There is an open-source framework Mercury that makes Python notebooks sharing painless. It converts notebooks to interactive documents (web apps, reports, slides, dashboards). You can share a notebook with interactive widgets. Your end-users can tweak widgets values and execute the notebook with new values (without changing the code). The Mercury allows to export the executed notebook into standalone HTML or PDF file. The end-user just need to clik the Download button.
Summary
Saving notebooks to PDF is a great way to persist results in a shareble format. PDFs can be easily published online or send in the email. There are several ways to convert Jupyter Notebook as PDF. The automatic conversion can be easily achieved with nbconvert tool. Notebooks shared with Mercury framework can be easily converted to PDF. The PDF notebook can be manually downloaded from the website.
Outstanding Data Science Tools
Jupyter – конвертация ноутбуков
Файлы ноутбуков Jupyter имеют расширение .ipynb . Записная книжка отображается в веб-браузере с помощью приложения Записная книжка. Его можно экспортировать в различные форматы файлов, используя параметр загрузки в меню файлов. Jupyter также имеет интерфейс командной строки в виде опции nbconvert . По умолчанию nbconvert экспортирует записную книжку в формат HTML. Вы можете использовать следующую команду для этой цели –
jupyter nbconvert mynotebook.ipynb
Это преобразует mynotebook.ipynb в mynotebook.html . Другой формат экспорта указывается в предложении `–to` .
Обратите внимание, что другие опции включают [‘asciidoc’, ‘custom’, ‘html’, ‘latex’, ‘markdown’, ‘notebook’, ‘pdf’, ‘python’, ‘rst’, ‘script’, ‘slides’]
HTML включает в себя «базовые» и «полные» шаблоны. Вы можете указать это в командной строке, как показано ниже –
jupyter nbconvert --to html --template basic mynotebook.ipynb
LaTex – формат подготовки документов, используемый специально для научного набора текста. Jupyter включает шаблоны «base», «article» и «report».
jupyter nbconvert --to latex –template report mynotebook.ipynb
Чтобы создать PDF через латекс, используйте следующую команду –
jupyter nbconvert mynotebook.ipynb --to pdf
Записную книжку можно экспортировать в слайд-шоу HTML. Преобразование использует Reveal.js в фоновом режиме. Чтобы обслуживать слайды HTTP-сервером, добавьте –postserve в командной строке. Чтобы создавать слайды, не требующие подключения к Интернету, просто поместите библиотеку Reveal.js в тот же каталог, где находится your_talk.slides.html .
jupyter nbconvert myslides.ipynb --to slides --post serve
Опция уценки конвертирует ноутбук в простой вывод уценки. Ячейки уценки не затрагиваются, а ячейки кода с отступом 4 пробела.
--to markdown
Вы можете использовать первую опцию, чтобы преобразовать блокнот в базовый вывод reStructuredText. Это полезно в качестве отправной точки для встраивания записных книжек в документы Sphinx.
--to rst
Это самый простой способ получить скрипт Python (или другой язык, в зависимости от ядра) из блокнота.
Как преобразовать записные книжки IPython в PDF и HTML?
Я хочу преобразовать свои блокноты ipython для печати их или просто отправить их в формате html. Я заметил, что уже есть инструмент для этого, nbconvert. Хотя я его скачал, я не имею понятия, как преобразовать блокнот, с помощью nbconvert2.py, так как nbconvert говорит, что он устарел. nbconvert2.py говорит, что мне нужен профиль для преобразования блокнота, что это? Есть ли документация об этом инструменте? python jupyter-notebook ipython
Поделиться Источник 14 апреля 2013 в 11:19
20 ответов
-
Для вывода HTML вам следует использовать Jupyter вместо IPython и выбрать Файл ->Загрузить как ->HTML (.html) или выполнить следующую команду:
jupyter nbconvert --to html notebook.ipynb
wkhtmltopdf notebook.html notebook.pdf
Оригинальная (в настоящее время почти устаревшая) версия: Преобразуйте файл IPython notebook в html.
ipython nbconvert —to html notebook.ipynb
Поделиться 19 сентября 2014 в 20:42
Также передайте флаг —execute для генерации выводимых ячеек
jupyter nbconvert --execute --to html notebook.ipynb jupyter nbconvert --execute --to pdf notebook.ipynb
Лучшая практика — сохранить вывод из блокнота для контроля версий, см.: Использование IPython-нот в управлении версиями
Но тогда, если вы не передадите —execute , вывод не будет присутствовать в HTML, см.: Как запустить.ipynb Jupyter Notebook из терминала?
Протестировано в Jupyter 4.4.0.
Поделиться 12 декабря 2017 в 12:58
Если вы хотите предоставить другим людям статический вид HTML или PDF вашего блокнота, используйте кнопку Печать. Это открывает статический вид документа, который вы можете распечатать в PDF с помощью возможностей вашей операционной системы или сохранить в файл с опцией «Сохранить» вашего веб-браузера (обратите внимание, что обычно это создаст как файл html, так и каталог с именем_файлов_блока_записи, который содержит все необходимые сведения о стиле, поэтому если вы намерены поделиться этим, вы должны отправить каталог вместе с основным файлом html).
Поделиться 14 апреля 2013 в 11:30
nbconvert еще не полностью заменён на nbconvert2, вы все еще можете использовать его, если хотите, иначе мы бы удалили исполняемый файл. Это просто предупреждение, что мы больше не исправляем ошибки nbconvert1.
Следующее должно работать:
./nbconvert.py --format=pdf yourfile.ipynb
Если вы используете достаточно новую версию IPython, не используйте режим печати, просто используйте обычный диалог печати. Ограничение графика в Chrome — известная проблема (Chrome не уважает некоторые файлы печати), и работает гораздо лучше с Firefox, а не все версии.
Что касается nbconvert2, он все еще очень хорошо разработан и документация должна быть написана.
Nbviewer использует nbconvert2, поэтому он довольно приличен с HTML.
Список текущих доступных профилей:
$ ls -l1 profile|cut -d. -f1 base_html blogger_html full_html latex_base latex_sphinx_base latex_sphinx_howto latex_sphinx_manual markdown python reveal rst
Дайте вам существующие профили. (Вы можете создать свою собственную, будущую документацию cf, ./nbconvert2.py —help-all должен дать вам некоторый вариант, который вы можете использовать в своем профиле.)
$ ./nbconvert2.py [profilename] --no-stdout --write=True
И он должен писать ваши (текстовые) файлы, пока извлечены цифры в cwd. Да, я знаю, что это не очевидно, и, вероятно, не изменится, поэтому никакая документация.
Причина этого заключается в том, что nbconvert2 будет в основном библиотекой для Python, где в псевдокоде вы можете сделать следующее:
MyConverter = NBConverter(config=config) ipynb = read(ipynb_file) converted_files = MyConverter.convert(ipynb) for file in converted_files : write(file)
Точка входа будет позже, как только API будет стабилизирован.
Я просто укажу, что @jdfreder (профиль Github) работает на экспорте tex/pdf/sphinx и является экспертом по генерации PDF из файла ipynb на момент написания этого.