Skip to content

About

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Notebook2PDF

Notebook2PDF is a completely local, zero-server web application designed to convert Jupyter Notebooks (.ipynb) into perfectly formatted PDF documents.

It was built to solve a common problem in academic and research environments: native Jupyter PDF exports often require massive LaTeX installations and frequently fail to wrap long lines of code, resulting in cut-off text on printed assignments. Notebook2PDF handles line wrapping, math rendering, and layout formatting instantly, right in your browser.

Architecture & How It Works

The core philosophy of Notebook2PDF is absolute privacy and zero server reliance.

When you drag and drop a .ipynb file into the application, the following process occurs entirely on your local machine:

  1. Local File Reading: The application uses the standard HTML5 File API to read the notebook. The file is never uploaded to an external server or database.
  2. JSON Parsing: A Jupyter Notebook is essentially a large JSON file. The application parses this JSON to extract the code, markdown, and output cells.
  3. Component Mapping: The parsed data is fed into React components. Markdown and LaTeX math equations are rendered using remark and KaTeX. Python code is styled using a custom Pygments-style syntax highlighter.
  4. Print CSS Engine: When you trigger the PDF download, the application strips away the user interface and applies strict @media print CSS rules. These rules force standard A4 margins, ensure long array outputs wrap to the next line, and prevent page breaks from splitting code cells in half.

Because everything happens in client-side JavaScript, the tool is stateless, secure, and works on restricted networks.

Features

  • 100% Private: Your code and data never leave your device.
  • Smart Code Wrapping: Custom CSS ensures long strings and arrays wrap cleanly within the document margins.
  • Zero Dependencies: Users do not need to install TeX Live, Pandoc, or any other heavy command-line tools to generate a PDF.
  • Math & Markdown Support: Fully supports standard Jupyter markdown, including complex LaTeX formulas.
  • Hot-Swapping: Dragging a new updated notebook over an open preview will instantly parse and replace the document.

Usage

To generate a PDF using the hosted version or your local build:

  1. Drop your .ipynb file into the upload zone.
  2. Review the parsed document in the preview window.
  3. Click "Download PDF" to open the browser's print dialog.
  4. Important: In your browser's print settings, ensure that Margins are set to "Default" or "None" and Background graphics is checked so the syntax highlighting colors appear correctly.

Local Development Setup

Notebook2PDF is built with React, TypeScript, and Vite. To run the project locally for development or contribution:

Prerequisites

  • Node.js (v18 or higher recommended)
  • npm or standard package manager

Installation

  1. Clone the repository:
   git clone https://github.com/vishwajeetbedse/Notebook2PDF.git
  1. Navigate into the project directory:
cd Notebook2PDF
  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev

The application will be available at http://localhost:5173.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages