Exporting a Jupyter notebook to PDF can be easy until a LaTeX dependency is missing, a plot disappears, or a long code cell breaks across pages. The right workflow depends on what matters most: a repeatable build, rich HTML output, minimal setup, or keeping a notebook on your own machine.
Here are five practical ways to convert an .ipynb file, with the trade-offs that are easy to miss.
Before you export: prepare the notebook
- Run the cells whose results should appear in the PDF, then save the notebook. An
.ipynbstores outputs alongside code; cells that were never run may have nothing to display. - Check plots, wide tables, and long code cells at normal page size. A notebook that looks good in a browser can still print with clipped content.
- Save a static image for interactive widgets if readers need to see them. A PDF cannot preserve the widget interaction.
- Keep linked images and data files available to the exporter, or embed the output where appropriate.
1. Export from Jupyter
In JupyterLab or Notebook, use the File menu’s export/download option and choose PDF when it is available. This is convenient for a one-off export because the notebook interface handles the file selection for you.
The PDF route commonly relies on nbconvert and a working TeX installation. If export fails with a missing xelatex or LaTeX package error, the problem is usually the local TeX toolchain rather than the notebook itself. Choose HTML or another route if you do not want to install TeX.
2. Use nbconvert with LaTeX
For a local or automated build, run:
jupyter nbconvert --to pdf notebook.ipynb
nbconvert’s PDF exporter generates LaTeX and compiles it to PDF. This is a good fit when you want a scriptable, version-controlled export and can manage TeX and its packages. It is also easier to reproduce across a team when everyone uses the same pinned environment.
If the command fails, read the first LaTeX error in the output. Installing a complete TeX distribution can take more space than the notebook workflow itself, so this method may be overkill for a quick share. See the nbconvert command-line guide for supported formats and options.
3. Use nbconvert’s WebPDF exporter
If you want a browser-rendered layout but still need a command-line build, try:
jupyter nbconvert --to webpdf notebook.ipynb
WebPDF renders the notebook to HTML and prints that page with headless Chromium. Install the exporter dependencies with pip install "nbconvert[webpdf]". It avoids the LaTeX compilation path, but it still needs Playwright and a compatible Chromium install. This is useful for CI or teams that already manage browser automation.
4. Export from Visual Studio Code
Open the notebook in VS Code, select the notebook toolbar’s … > Export, and choose PDF. The VS Code notebook guide notes that PDF export requires TeX. It also warns that SVG-only outputs may not appear in the PDF; exporting to HTML and printing that page can be a workaround for those graphics.
This is a straightforward option if VS Code is already where you review the notebook. It does not remove the underlying export dependencies, so check the environment before promising a PDF to someone else.
5. Use a browser-based conversion workflow
For an occasional export without setting up Python, TeX, or a local command, use a browser-based converter. Download the .ipynb from Jupyter, Colab, or Kaggle, open it in the converter, review the rendered notebook, and print or save it as PDF.
I maintain ipynbtopdf, a free browser-based converter. It reads the notebook locally in the browser and renders Markdown, code, math, tables, and saved plots before using the browser’s print dialog. Interactive widgets still need a saved static image. As with any online tool, check the privacy model before using it with confidential notebooks; this workflow is designed not to upload the notebook to a conversion server.
Which method should you choose?
| Situation | Good starting point | Main trade-off |
|---|---|---|
| A one-off export from Jupyter | Jupyter’s PDF export | Usually depends on TeX |
| Repeatable local or CI builds | nbconvert --to pdf |
TeX setup and package errors |
| HTML-like rendering in automation | nbconvert --to webpdf |
Playwright and Chromium setup |
| You already review notebooks in VS Code | VS Code Export | TeX required; SVG-only output may be missing |
| No local Python or TeX setup | Browser-based conversion | Review privacy and print layout |
Final PDF check
Before sharing, open the PDF once and confirm that the equations rendered, plots are present, wide tables are readable, code is not clipped, and the final page is not blank. If a result depends on a widget or external file, include a static version. Choosing the export route up front saves more time than troubleshooting a PDF after it has already been sent.
For a step-by-step walkthrough of choosing a route and checking the result, see the Jupyter notebook to PDF guide.
Top comments (0)