Effortless Jupyter Notebook to PDF in VS Code: Meet nb2pdf
If you’ve ever tried to submit a Jupyter notebook as a PDF, you already know the pain:
- “Print to PDF” from the browser looks ugly.
-
nbconvertand LaTeX often break or need painful setup. - Copy–paste into Word takes 30–60 minutes per assignment.
- DataFrames turn into messy text instead of clean tables.
For learners, developers, and especially students who work heavily in Jupyter, this becomes a recurring headache every time an assignment or report is due.
That’s why I built nb2pdf – a VS Code extension that converts your .ipynb notebook into a clean, professional PDF in just a few clicks.
What is nb2pdf?
nb2pdf is a Visual Studio Code extension that:
- Takes any
.ipynbnotebook - Automatically runs it (so all cells are executed)
- Captures the outputs (including pandas tables and graphs)
- And generates a beautifully formatted PDF – right from VS Code
Under the hood, it uses a Python script and the reportlab library to render:
- Syntax-highlighted code (VS Code style)
- DataFrames as proper tables
- A clean layout suitable for submissions and reports
You don’t have to fight with LaTeX or upload your notebook to random online converters. Everything runs locally on your machine.
Key Features
Here’s what nb2pdf focuses on:
🎨 Syntax highlighting
Code uses a VS Code–like theme, with colored keywords, strings, and comments for easy reading.
💡 This makes the PDF much closer to how you see the notebook inside VS Code.
📊 Beautiful DataFrame tables
Pandas DataFrames render as clean, bordered tables instead of dense text blobs.
No more screenshots of tables or broken formatting when you export.
🧾 Header with your details (optional)
You can configure your(Optional):
- Name
- ID
- Project Title
- Project SubTitle
via a nb2pdf extension settings, so every page looks like a professional report.
📄 Submission-ready layout
Page numbers, margins, spacing, and sectioning are designed to look good when you send the PDF to a:
- Professor
- Manager
- Client
⚡ Fast and local
nb2pdf runs your notebook and builds the PDF in seconds – with no uploading to external services.
When is nb2pdf useful?
nb2pdf is especially helpful for:
🎓 Students
- Submit assignments in professional PDF format
- Impress teachers with clean, readable reports
- Save hours of manual formatting
- Keep submissions consistent across group projects
👨🏫 Educators
- Receive standardized, easy-to-grade submissions
- No need to run students’ code locally
- Get clear visibility of both code and outputs
- Ensure fair evaluation with consistent formatting
💼 Professionals
- Document data analysis projects
- Share work with non-technical stakeholders
- Create portfolio-ready artifacts
- Generate client-friendly reports
🔬 Researchers
- Share reproducible analysis in a stable format
- Submit supplementary materials alongside papers
- Document experimental results clearly
- Archive computational work for future reference
Getting Started: Step-by-Step
You only need to do three things:
- Install the VS Code extension
- Install the Python dependency
- Convert your notebook from inside VS Code
1️⃣ Install the nb2pdf VS Code Extension
Open Visual Studio Code and:
- Go to the Extensions view (left sidebar).
- Search for
nb2pdf - Notebook to PDF(Publisher:GaneshKumbhar). - Click Install.
Extension link:
👉 nb2pdf – Notebook to PDF on Visual Studio Marketplace
Searching and installing the “nb2pdf – Notebook to PDF” extension from the VS Code Extensions view.
2️⃣ Install the Python Dependency
nb2pdf uses the reportlab library under the hood to generate PDFs.
In your terminal (VS Code integrated terminal or system terminal), run:
pip install reportlab
Make sure you’re using the **same Python environment** that VS Code uses for your notebook.
3️⃣ Convert a Notebook to PDF from VS Code
Once the extension and Python library are ready:
- In VS Code’s Explorer, right-click on any
.ipynbfile. - You’ll see
nb2pdfcommands such as:- “Convert to PDF (nb2pdf)”
- Or similar options that automatically run the notebook and generate a PDF, including all outputs like DataFrame tables and plots.
- Click the desired option.
- Wait a few seconds – a PDF will be generated in your workspace (usually next to the notebook, or as configured by the extension).
Option 1:
Right-clicking a Jupyter notebook in VS Code and choosing “Convert to PDF (nb2pdf)”
4️⃣ (Optional) Add Your Name, ID, and Course Details
If you want a professional header on first page (for example, for Python assignments), nb2pdf lets you configure it through extension settings
Go to Extension -> Settings

Fill the details.
The nb2pdf engine will use these values to render a clean header at the top of each page in the PDF.
📷 PDF Header Example
Example of the PDF header showing name, ID, Title, and Subtitle.
5️⃣ Preview the Final PDF
Open the generated PDF with your default viewer and check:
- Code blocks with proper syntax highlighting
- DataFrames rendered as formatted tables
- Graphs / plots rendered correctly
- Header and page numbers as expected
Final PDF Generated Example
Behind the Scenes: Open Source & CLI
The nb2pdf engine itself is open source and available as a standalone Python script in the GitHub repository (nb2pdf.py).
👉 GitHub repo: https://github.com/ganesh250684/nb2pdf
That means you can:
- Run it directly from the command line:
python nb2pdf.py your_notebook.ipynb
- Customize configuration, headers, and output paths.
- Explore the code, open issues, and contribute.
If you like the project, you can also ⭐ star the repository and share feedback or feature requests.
Tips to Get the Best Results
A few practical tips:
- ✅ Run all cells before converting (or use the option that auto-runs the notebook) so all outputs are fresh.
- 📏 Keep DataFrames reasonably sized per cell; huge tables can make PDFs very long.
- 🧩 Use clear markdown headings in the notebook; they carry over nicely into the PDF structure.
Conclusion
Exporting Jupyter notebooks to a clean PDF shouldn’t be a mini-project every time.
With nb2pdf as a VS Code extension, you can:
- Stay inside VS Code
- Right-click your notebook
- Get a polished PDF with proper code, tables, and layout
…all in just a few seconds.
If you find nb2pdf useful, you can:
- ⭐ Star the GitHub repo: https://github.com/ganesh250684/nb2pdf
- Share it with classmates or colleagues
- Leave a review or rating for the extension in the Visual Studio Marketplace
And of course, feel free to connect with me on LinkedIn if you’d like to follow more tools, AI experiments, and productivity ideas.








Top comments (0)