electrobun-pdf

September 7, 2026 · View on GitHub

Local-first PDF & DOCX editor built with Electrobun. Open, annotate, and export documents — nothing leaves your machine.

Welcome Screen

Features

  • Open PDF & DOCX files with a native file picker — or drag & drop a file anywhere in the window
  • Pixel-perfect PDF rendering via MuPDF WASM — logos, fonts, form fields all preserved
  • Annotate PDFs — add text, draw circles/ovals, choose colors, adjust stroke width
  • Drag & drop annotations — reposition text and shapes after placing them
  • Delete annotations — hover any annotation in select mode and click the red ×
  • Undo/Redo — Cmd+Z / Cmd+Shift+Z, multi-level and across all pages (the affected page scrolls into view)
  • Page indicator — the status bar tracks the current page as you scroll
  • Export to PDF — saves annotated documents with a native folder picker
  • DOCX editing — full rich text editor powered by TipTap
  • Lightweight — ~12MB app bundle using system WebKit (no bundled Chromium)

Before & After

Original PDFAfter annotation
BeforeAfter

Keyboard Shortcuts

KeyAction
VSelect / move tool
TText annotation tool
CCircle / oval tool
EscBack to select mode / finish text editing
Cmd+ZUndo
Cmd+Shift+ZRedo
Double-click textEdit placed text
Hover annotation + ×Delete annotation (select mode)

Empty text boxes are discarded automatically when you click away, so a stray click with the text tool never leaves invisible annotations behind.

Getting Started

Prerequisites

  • Bun v1.4+ — for installing dependencies and running scripts; the packaged app runs its main process on Cottontail and does not ship Bun
  • macOS 14+, Windows 11+, or Ubuntu 22.04+

Install & Run

git clone https://github.com/GijungKim/electrobun-pdf.git
cd electrobun-pdf
bun install
bun run start

bun run start prepares the Electrobun 2 devkit, builds the frontend with Vite, and launches the app. On the first run, Electrobun downloads its paired Hutch toolchain into ~/.hutch and projects the SDK into the ignored .hutch/devkit directory.

For development with hot reload:

bun run dev:hmr

Verify & Package

bun run typecheck
bun test
bun run build:canary

For a stable-channel package, run bun run build:stable. Packaging writes ignored local output under build/ and artifacts/; it does not publish a release. The current project configuration produces unsigned development artifacts, so configure application icons, platform signing, and release.baseUrl before distributing builds publicly.

Architecture

src/
  bun/                  # Main process (runs on Cottontail, Electrobun's JSC runtime)
    index.ts            # Window, menus, RPC handlers, file I/O
    fileParser.ts       # PDF rendering (MuPDF) & DOCX parsing (Mammoth)
  mainview/             # Webview (React + Tailwind)
    App.tsx             # App shell, state management
    rpc.ts              # RPC bridge to main process
    components/
      WelcomeScreen.tsx
      PdfToolbar.tsx    # Annotation tool bar
      PdfAnnotationLayer.tsx  # Text & circle annotations per page
      Toolbar.tsx       # DOCX rich text toolbar
      StatusBar.tsx
    utils/
      fileHandlers.ts   # PDF export via jsPDF
      docExport.ts      # DOCX (ProseMirror JSON) → styled PDF blocks & line layout
      annotations.ts    # Per-page annotation document (immutable snapshots)
      history.ts        # Generic undo/redo history over those snapshots
      geometry.ts       # Coordinate helpers
  shared/
    types.ts            # Typed RPC schema

How it works

StepWhat happens
Open PDFThe main process reads the file, MuPDF (WASM) renders each page as a PNG, sent to webview page-by-page via fire-and-forget RPC
Open DOCXThe main process reads the file, Mammoth converts to HTML, sent to webview and loaded into TipTap editor
Drag & dropThe webview reads the dropped file's bytes and sends them to the main process over RPC (base64), then the same parse/render path runs
AnnotateReact components overlay SVG circles and positioned text inputs on top of page images
ExportjsPDF composites page images + annotation coordinates directly onto PDF pages (no html2canvas)

Key dependencies

PackagePurpose
ElectrobunDesktop shell (native webview + Cottontail main process)
MuPDFPDF page rendering (WASM)
MammothDOCX to HTML conversion
TipTapRich text editor (ProseMirror)
jsPDFPDF generation for export

License

MIT