Jupyter to PDF
Export Jupyter notebooks (.ipynb) to beautifully formatted PDFs directly from VS Code — with syntax highlighting, embedded images, rendered markdown, math formulas, table of contents, and a clean LaTeX-inspired design.
Features
- Table of contents — auto-generated from markdown headings (H1, H2, H3) with clickable links
- Math formulas — LaTeX math rendered with KaTeX (
$E=mc^2$, $$\sum_{i=1}^{n}$$)
- Clean, compact layout — LaTeX-inspired design with Arial Narrow typography and justified text
- Syntax highlighting — code cells with color-coded Python (and 15+ other languages)
- All images supported — matplotlib/plotly outputs, pasted screenshots (attachments), and markdown-referenced images
- Rendered markdown — headings, lists, tables, blockquotes, inline code, links
- DataFrame tables — pandas HTML outputs render as styled tables with alternating row colors
- Execution labels —
In [1]: / Out [1]: labels like classic Jupyter
- Author & date header — centered title, author name, and auto-generated date
- Running header/footer — title and author on every page with page numbers
- Brand mark — subtle notebook→PDF logo in the top-right corner
- Dark theme — optional dark mode PDF output
- Multiple export methods:
- Command palette (
Ctrl+Shift+P)
- Right-click on
.ipynb in the file explorer
- Button in the notebook toolbar
- Configurable — font size, margins, theme, toggle outputs/markdown on or off
Requirements
- VS Code 1.85+
- Google Chrome or Chromium installed on your system
Installation
From the Marketplace
Search for "Jupyter to PDF" in the VS Code Extensions panel, or:
code --install-extension MarioCarvajal.jupyter-to-pdf
From source
git clone https://github.com/your-repo/jupyter-to-pdf-extension.git
cd jupyter-to-pdf-extension
npm install
npm run compile
npx vsce package
code --install-extension jupyter-to-pdf-0.8.0.vsix
Usage
Option 1: Command palette
- Open a
.ipynb file in VS Code
- Press
Ctrl+Shift+P
- Type "Jupyter to PDF" and select "Exportar notebook activo"
Option 2: Right-click
- Right-click any
.ipynb file in the Explorer panel
- Select "Exportar a PDF"
When viewing a notebook, click the PDF icon in the top toolbar.
Export flow
Before generating the PDF, you'll be prompted with 3 editable fields:
- 📄 Title — pre-filled with the notebook filename, editable to any custom title
- ✍️ Author — pre-filled from Settings (or empty on first use), editable each time
- 📅 Date — pre-filled with today's date, editable to any date or text
All three appear in the PDF header. You can cancel at any step to abort. To skip the author prompt permanently, save your name in Settings → Jupyter to PDF → Author.
Math Support
The extension renders LaTeX math formulas using KaTeX. Use standard LaTeX delimiters in your markdown cells:
Inline math: $E = mc^2$ renders as E = mc²
Display math:
$$\hat{\beta} = (X^T X)^{-1} X^T y$$
KaTeX is only loaded when the notebook contains math formulas, so there's no performance impact on notebooks without math.
Table of Contents
If your notebook has 3 or more markdown headings (#, ##, ###), a table of contents is automatically generated after the title header. The TOC entries are clickable links that navigate to each section. Heading levels are visually indented:
- H1 — bold, no indent
- H2 — indented
- H3 — double indented
Configuration
Go to Settings (Ctrl+,) and search for "Jupyter to PDF":
| Setting |
Default |
Description |
jupyterToPdf.fontSize |
9 |
Base font size in pt |
jupyterToPdf.author |
"" |
Author name shown in the PDF header |
jupyterToPdf.theme |
light |
PDF theme: light or dark |
jupyterToPdf.includeOutputs |
true |
Include cell outputs in the PDF |
jupyterToPdf.includeMarkdown |
true |
Include rendered markdown cells |
jupyterToPdf.syntaxHighlight |
true |
Apply syntax highlighting to code |
jupyterToPdf.margins |
{top:50, right:40, bottom:50, left:40} |
Page margins in points |
PDF Design
The exported PDF uses a hybrid style inspired by LaTeX documents and Google Colab:
- Typography: Arial Narrow throughout
- Header: centered title, author, date, with horizontal rule
- Table of contents: auto-generated with clickable links
- Code cells: light gray background with syntax highlighting, wrapped in bordered container
- Outputs: displayed below code with separator line and
Out [n]: labels
- Images: centered at 85% width with subtle border and shadow
- Tables: compact font, alternating row stripes, header highlighted
- Math: KaTeX-rendered LaTeX formulas (inline and display)
- Running header: title (left) and author (right) on every page
- Page numbers: centered at the bottom of each page
- Brand: notebook→PDF logo in the top-right corner of the first page
How It Works
.ipynb (JSON)
↓ notebookParser.ts — reads cells, outputs, attachments, images
↓ htmlRenderer.ts — converts to styled HTML with TOC, KaTeX, highlight.js
↓ pdfGenerator.ts — renders HTML to PDF via Puppeteer + Chrome
↓
Final PDF
Project Structure
jupyter-to-pdf-extension/
├── src/
│ ├── extension.ts — entry point, registers commands
│ ├── notebookParser.ts — parses .ipynb JSON into structured cells
│ ├── htmlRenderer.ts — converts cells to styled HTML with TOC + KaTeX
│ └── pdfGenerator.ts — HTML to PDF with Puppeteer
├── package.json — extension metadata and configuration
├── LICENSE — MIT license
├── .vscodeignore — excludes dev files from package
├── tsconfig.json
└── README.md
Changelog
v0.8.0
- Added auto-generated Table of Contents from markdown headings
- Added KaTeX math formula rendering ($...$ and $$...$$)
- Added 3-step export flow: editable title, author, and date before generating PDF
- Added MIT LICENSE file
- Added .vscodeignore to reduce package size
- Improved math expression protection during markdown parsing
v0.7.0
- Running header on all pages (title + author)
- Page numbers in footer
- Code/output separation with divider line
- Images with border and shadow
- Responsive DataFrame tables with smaller font
- Improved line height for long text paragraphs
v0.6.0
- Added custom extension icon
- Published to VS Code Marketplace
v0.5.x
- Notebook attachment support (pasted images)
- Relative image path resolution
- Compact LaTeX-inspired design with Arial Narrow
- Author name prompt and configuration
- Brand logo in top-right corner
v0.4.x
- Notebook viewer detection (not just text editor)
- Dark theme support
- Configurable font size, margins, theme
v0.1.0
- Initial release
- Basic notebook to PDF conversion
- Syntax highlighting, markdown rendering, image embedding
Known Limitations
- Requires Chrome/Chromium — won't work without a Chromium browser installed
- Interactive widgets — ipywidgets and interactive plotly charts don't render (static images do)
- Very wide tables — tables with 15+ columns may get clipped at page edges
- KaTeX requires internet — math formulas need CDN access for first render
Roadmap
- [ ] Export only selected cells
- [ ] Hide code option (output-only export for non-technical reports)
- [ ] Custom header with institution logo
- [ ] Batch export (multiple notebooks at once)
- [ ] Plotly static image fallback
- [ ] Additional design templates
License
MIT