Skip to content

Repository files navigation

🔥 PDF Forge

An advanced, fully local PDF editor that runs in your browser. Import almost anything, draw & annotate, and export with precise size control — your files never leave your machine.

PDF Forge


✨ Features

Import almost anything

  • PDF — rendered page-by-page, original bytes kept for crisp re-export
  • Images — PNG, JPG, WebP, GIF, BMP, AVIF, ICO
  • SVG — vector graphics rasterized to a page
  • Text & Markdown — typeset into clean paginated pages (headings, lists, code, quotes)
  • Word (.docx) — converted via Mammoth (headings/paragraphs/lists; flagged as simplified)
  • Drag-and-drop or multi-file open — files are merged into one document

Draw & edit

  • ✏️ Pen (smoothed freehand) · 🖍️ Highlighter (true multiply blend)
  • Rectangle · ⬭ Ellipse · ╱ Line · ➜ Arrow (with Shift to constrain)
  • Form-friendly text boxes with inline editing, font size, bold/italic, color, and alignment
  • Signatures — draw, type, or upload a signature and place it on the PDF
  • Cleanup / whiteout — cover PDF content you are authorized to edit
  • 🧽 Annotation eraser, full select / move / resize / rotate, marquee selection
  • Per-object color, fill, stroke width, opacity, z-order (bring forward / send back)

Page operations

  • Reorder (drag thumbnails), rotate 90°, duplicate, delete, insert blank
  • Merge multiple files, export any page range (1-3,5)

Powerful export — the headline feature

  • Formats: PDF, PNG, JPG, WebP, SVG, TXT (extracted text)
  • Name before download — choose the final file name inside the export dialog
  • 🎯 Target-size mode — set a ceiling like "< 7 MB" and PDF Forge auto-tunes render resolution and compression (binary search) to fit under it
  • Manual mode — quality + resolution (DPI) sliders
  • Export settings are remembered on the same device
  • 🗜️ Zip toggle — bundle the export into a .zip (multi-file exports zip automatically)
  • Keep PDF text sharp — untouched original pages are re-exported as vectors (tiny & crisp); only annotated pages are flattened
  • White-background / flatten option for transparent formats

Workflow

  • ⏪ Unlimited undo/redo, zoom & pan (Ctrl+scroll / Space-drag), fit-to-window
  • Rich keyboard shortcuts, polished dark UI, fully offline
  • No sign-up, plus built-in Terms and Privacy links with contact info

🚀 Run locally (Windows / macOS / Linux)

npm install
npm run dev

Open the printed URL (default http://localhost:5173). That's it — it's a static app, so it works fully offline and nothing is uploaded anywhere.

Build / preview a production bundle

npm run build     # outputs to dist/
npm run preview

Chrome extension

npm run build:extension

Then open chrome://extensions, enable Developer Mode, choose Load unpacked, and select the generated dist/ folder. The extension popup opens PDF Forge in a full browser tab and can start directly in Sign, Cleanup, or Fill mode.

macOS app wrapper

npm run build
npm run mac:run

The macOS wrapper lives in macos/PDFForgeMac and loads the shared web app from dist/ using WKWebView. It includes native File, Edit, and View menus wired to the editor.

☁️ Deploy to Vercel

This repo is Vercel-ready (vercel.json included). Either:

  • Import the GitHub repo at vercel.com/new — framework auto-detects as Vite, or
  • npm i -g vercel && vercel

The build command is npm run build and the output directory is dist.


⌨️ Keyboard shortcuts

Key Action Key Action
V Select / move T Text
H / Space Pan I Place image
P Pen S Signature
M Highlighter W Cleanup / whiteout
E Erase annotations Ctrl+Z / Y Undo / redo
R / O Rectangle / ellipse Ctrl+A Select all on page
L / A Line / arrow Ctrl+D Duplicate
Ctrl+scroll Zoom Ctrl+E Export
Ctrl+0 Fit to window Delete Delete selection
Shift (while drawing) Constrain to square / circle / 45° Arrows Nudge selection

🧪 Testing

npm test                 # unit tests (Vitest) — geometry, size-tuner, importers, range parsing
npx playwright test      # end-to-end tests (Chromium) — real import/export round-trips
swift build --package-path macos/PDFForgeMac

The e2e suite validates real exports by magic bytes (PDF %PDF, PNG, JPEG, ZIP), confirms target-size tuning actually lands under the ceiling, and checks the import pipeline and UI download.


🏗️ How it works

Concern Tech
UI React 18 + TypeScript + Tailwind, built with Vite
State / history Zustand store with snapshot-based undo/redo
PDF rendering pdfjs-dist (web worker)
PDF writing pdf-lib (vector passthrough + raster flatten)
DOCX / Markdown mammoth + marked → block typesetter on canvas
Zip JSZip
Drawing Custom canvas scene-graph (shared renderer for screen and export, so WYSIWYG)

All processing happens client-side — there is no server and no upload.


📄 License

MIT © Nihar

About

Advanced local PDF editor in the browser - import anything, draw & annotate, export with target-size control & optional zip.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages