Convert a Jupyter notebook to PDF without nbconvert or LaTeX
Jupyter's built-in PDF export runs jupyter nbconvert --to pdf, which typesets the notebook through LaTeX. On a laptop without TeX Live or MiKTeX it stops with "xelatex not found", and on a locked-down work or school computer you often can't install it. This page skips that: it reads the notebook's JSON in your browser and lays out each cell as PDF text and images.
| Method | What you need | Text in PDF | Math | Best for |
|---|---|---|---|---|
| This page | A browser | Selectable | LaTeX source | Quick hand-ins, reports, any computer |
nbconvert --to pdf |
Python, nbconvert, TeX Live or MiKTeX | Selectable | Typeset | Math-heavy papers |
nbconvert --to webpdf |
Python, nbconvert, headless Chromium | Selectable | Typeset (MathJax) | Looks like the notebook screen |
| Browser Print to PDF | A running Jupyter or Colab tab | Selectable | As on screen | One-off, but page breaks cut charts |
What a notebook looks like as a PDF
Each cell becomes a block on the page, in order:
- Markdown cells: headings, lists, tables, links, bold and italic. Images pasted into a cell (attachments) are included.
- Code cells: monospaced on a grey band, with Python keywords, strings, comments and numbers in colour, and the In [n] label. Indentation is kept; long lines wrap.
- Printed output and logs: as plain text. Warnings on stderr get a pale orange band, and progress bars that redraw themselves show only their final line.
- Charts: matplotlib, seaborn and other PNG, JPEG or SVG figures, scaled to the page width.
- DataFrames: the HTML table pandas shows, with borders. Scripts and styles inside HTML output are removed.
- Errors: the full traceback on a pale red band, without the terminal colour codes that otherwise print as
[0;31m.
We measured these test notebooks in desktop Chrome:
| Test notebook | File size | Cells | PDF (Letter) | Code hidden | Time |
|---|---|---|---|---|---|
| Sales analysis: DataFrame, 2 charts, SVG, traceback | 14 KB | 9 | 3 pages, 17 KB | 2 pages, 14 KB | 0.4 s |
| Training log: 30 code cells, 6 charts | 48 KB | 31 | 7 pages, 34 KB | 6 pages, 25 KB | 0.5 s |
| Model report: 20 retina (1200 px) charts | 627 KB | 21 | 14 pages, 466 KB | 10 pages, 453 KB | 2.2 s |
How to hide code when converting a notebook to PDF
Tick Hide code (inputs) before converting. Code cells and their In [n] labels are left out; their outputs, and every Markdown cell, stay. This is the browser equivalent of jupyter nbconvert --no-input, and it's what most managers and clients want: the story and the charts, not the pandas calls.
Turning in a notebook as a PDF
For Gradescope and Canvas assignments
Many data science courses ask for a PDF of the executed notebook so graders can annotate it. Run all cells, save, convert, and check every question's output is on a page before uploading. If the PDF is over the course's size limit, run it through Compress PDF.
For a report to a manager or client
Tick Hide code, keep page numbers on, and choose A4 or Letter to match the reader's printer. Merge it with a cover page using Merge PDF.
For a Kaggle or Colab notebook
Download the .ipynb from Colab (File > Download) or Kaggle (File > Download notebook) and drop it here. Outputs saved in the file are printed.
For archiving an analysis
A PDF keeps the results as they were on the day you ran them, readable without Python. Keep the .ipynb too if you might need to re-run it.
Troubleshooting
| Problem | Fix | Why it happens |
|---|---|---|
| Charts or results are missing | Run all cells, save, download the .ipynb again, convert. | Only outputs saved in the file can be printed. |
| A box says "Interactive output can't be printed" | Save the chart as an image (for Plotly: fig.show("png")), re-run, convert. |
Plotly, Bokeh and widgets need JavaScript to draw. |
| Characters appear as "?" | Rename emoji or symbols in Markdown, or accept the substitution. | The built-in PDF fonts cover Latin script only. |
Equations show as $...$ |
Use nbconvert with LaTeX for typeset math. | Math is printed as its source. |
| "This file isn't valid notebook JSON" | Download the notebook again from Jupyter or Colab. | The file is cut off, or it's a .py script, not an .ipynb. |
| A wide DataFrame is squeezed | Show fewer columns (df.iloc[:, :8]) before saving. |
Tables are fitted to the page width. |