IPYNB to PDF Converter
Turn a .ipynb file into a PDF with its charts, tables and maths, with no LaTeX and nothing to install. Print the code with it, or only the outputs for a report. The notebook never leaves your device.
Open a Jupyter notebook
Drop a .ipynb file here, choose one or paste it. No Jupyter, no install, no upload.
No LaTeX and no install: your browser prints the notebook below. In the print dialog, pick Save as PDF as the printer.
Bike rides and rain: a short walkthrough
A week of made-up numbers from a small town's bike-share scheme. It shows what a notebook can hold: Markdown, code, a table, a chart, maths, a warning and, at the end, an error.
import pandas as pd
import matplotlib.pyplot as pltrides = pd.DataFrame({
"day": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
"trips": [412, 438, 395, 451, 288, 230],
"rain_mm": [0.0, 1.2, 4.5, 0.0, 9.8, 14.1],
}).set_index("day")
rides| trips | rain_mm | |
|---|---|---|
| day | ||
| Mon | 412 | 0.0 |
| Tue | 438 | 1.2 |
| Wed | 395 | 4.5 |
| Thu | 451 | 0.0 |
| Fri | 288 | 9.8 |
| Sat | 230 | 14.1 |
How busy was the week?
The mean number of trips per day is
where is the number of days and is the number of trips on day .
mean = rides["trips"].mean()
print(f"Mean trips per day: {mean:.1f}")
print(f"Busiest day: {rides['trips'].idxmax()}")Mean trips per day: 369.0 Busiest day: Thu
import warnings
if rides["rain_mm"].max() > 10:
warnings.warn("Saturday had over 10 mm of rain; the gauge reads high in storms.")/tmp/ipykernel_4120/2715331896.py:4: UserWarning: Saturday had over 10 mm of rain; the gauge reads high in storms.
warnings.warn("Saturday had over 10 mm of rain; the gauge reads high in storms.")
Rain and riding
Fewer people rode on wet days. Pearson’s correlation coefficient measures how closely two columns move together, from −1 to 1:
fig, ax = plt.subplots(figsize=(6.4, 3.6))
ax.bar(rides.index, rides["trips"], color="#4878d0")
ax.set_ylabel("Trips")
ax.set_title("Bike-share trips per day")
plt.show()round(rides["trips"].corr(rides["rain_mm"]), 3)-0.979
A day that isn’t there
There is no Sunday in the data, so asking for it raises a KeyError. This is what a traceback looks like:
rides.loc["Sun"]KeyError: 'Sun'
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) Cell In[7], line 1 ----> 1 rides.loc["Sun"] File ~/.venv/lib/python3.12/site-packages/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key) 3810 return self._engine.get_loc(casted_key) 3811 except KeyError as err: -> 3812 raise KeyError(key) from err KeyError: 'Sun'
What next
- Load a week of rides
- Chart them
- Add the weekend’s weather from the town’s own gauge
Made-up data, made for this example. Any resemblance to a real town is a coincidence.
Your notebook is read on this device and never uploaded. Check it yourself
How this works: Method, 5 sources,
How this works
Method
The .ipynb file is read in the browser as the nbformat JSON it is: every cell, its last outputs and its attachments. Markdown is drawn with GitHub Flavored Markdown and maths with KaTeX, code is coloured by the notebook’s language, and each output shows its richest format, as JupyterLab chooses. All HTML from the notebook is sanitised first and nothing from other sites is loaded. PDF comes from the browser’s print engine; HTML, script and Markdown files are written in the page.
Sources
Privacy
On your device. Nothing you enter or open leaves this browser. About privacy labels
Changes
- First published: open a .ipynb file with its outputs, maths and colours, and save it as PDF, HTML, a script or Markdown.
Why a notebook PDF is usually hard, and why this one isn’t
The standard way to make a PDF from a notebook is jupyter nbconvert --to pdf. It converts the notebook to LaTeX and then typesets it with XeTeX, so it only works once a full TeX distribution is installed, which runs to several gigabytes. Without one, the command stops with an error that xelatex was not found. That error is one of the most common reasons people look for another way.
This converter skips LaTeX. Your browser already knows how to lay a page out on paper, so the notebook is drawn as a print document and handed to the browser’s own Save as PDF. Equations are set by KaTeX, code keeps its colours, pandas tables keep their rows, and charts print at their full resolution. Long code lines wrap instead of running off the page.
Choose Outputs only when the PDF is a report for someone who doesn’t read code: the explanation, tables and charts stay and the code cells drop out. Students handing in homework usually want the opposite, every cell with its In [n] number, which is the default.
Paper size follows your setting in Settings, Units (US Letter or A4), and each cell is kept on one page where it fits. Interactive charts that need a running kernel print as a short note, or as the still picture the notebook saved with them.
Good to know
- nbconvert’s PDF export goes through LaTeX and the XeTeX engine, so it needs a TeX distribution installed alongside Jupyter. Source: nbconvert documentation: Installation
- Its other route, --to webpdf, prints the HTML version with a headless Chromium browser, which is an extra install: pip install nbconvert[webpdf]. Source: nbconvert documentation: Installation
How to convert a Jupyter notebook to PDF3 steps, all on your device
- Open the notebook. Drop the .ipynb file on the card or choose it. Check that it looks right: everything on screen is what goes on paper.
- Choose what to print. Keep the code, or pick Outputs only for a report that shows the writing, tables and charts without the code. Folded cells print folded.
- Save as PDF. Press Save as PDF, look over the preview, then choose Save as PDF (or Microsoft Print to PDF) as the printer in your browser’s print dialog.
Frequently Asked Questions
Do I need LaTeX or nbconvert?
No. The PDF is made by your browser’s print engine from the notebook drawn on this page. There is no LaTeX step, so there is no xelatex error and nothing to install.
How do I make a PDF without the code?
Choose Outputs only before you save. The Markdown, tables, charts and printed results stay, and the code cells are left out, which reads better as a report.
Why does Save as PDF open a print dialog?
Browsers save PDFs through their print dialog. Pick Save as PDF as the printer in Chrome or Edge, Save to PDF in Firefox, or PDF, Save as PDF on a Mac. On a phone, use the share or print option and choose to save the file.
Are links and text in the PDF selectable?
Yes. The browser writes real text into the PDF, so you can search it, copy from it and click its links, unlike a PDF made from screenshots.
“Jupyter” is a trademark of Project Jupyter, used here only to say which files this viewer opens. Binary Decimal is not affiliated with or endorsed by Project Jupyter.