Repository avatar
Browser Automation
v1.0.0
active

pdf-dark

io.github.1436941541/pdf-dark

Invert PDF colors and convert PDFs to dark mode with theme presets and browser tools.

Documentation

🌙 PDF Dark

Convert any PDF to dark mode — entirely in your browser. No upload, no signup, free.

Live: pdfdark.org

PDF Dark turns any PDF into a dark-themed downloadable file. The entire conversion runs in your browser via PDF.js and a Web Worker — your file never touches a server. A saturation-based algorithm preserves photos and charts in their original colors while darkening the rest.

Why this exists

Reading long PDFs at night meant either staring at a bright white page or uploading sensitive documents (research papers, contracts, medical records) to "PDF dark mode" services I didn't fully trust. The "invert colors" toggles in existing tools also wreck photos and charts — turning portraits into negatives and graphs into noise.

So PDF Dark was built around two non-negotiable defaults:

  1. Nothing leaves your browser. Verify it yourself in DevTools → Network.
  2. Images keep their original colors. Only text and UI elements get themed.

Features

  • 100% browser-side — file processed via File API + Web Worker + OffscreenCanvas
  • Image preservation — saturation classifier keeps photos and charts in original colors
  • Real PDF output — image-based PDF, opens dark in any reader (Kindle, iPad, Acrobat, Preview)
  • 4 dark themes — pick your preferred contrast
  • No signup, no tracking — Sentry runs only on errors, with full content masking
  • Mobile support — works on iOS Safari and Android Chrome
  • Free — and intends to stay that way

How it works

Drop PDF
  → PDF.js parses each page to canvas
  → Web Worker classifies pixels by saturation
       ├─ saturated pixels (images, charts)  → preserved
       └─ low-saturation pixels (text, UI)   → inverted / themed
  → pdf-lib stitches a new PDF
  → User downloads

The saturation classifier runs on OffscreenCanvas inside a Web Worker, so the UI thread never blocks even on large PDFs.

Stack

Privacy

Your PDF never leaves your browser. The conversion uses only:

  • File API (local file read)
  • Web Worker (off-main-thread processing)
  • OffscreenCanvas (per-pixel manipulation)
  • Blob + URL.createObjectURL() (download trigger)

Verify yourself: open DevTools → Network → drop a PDF. No upload requests appear.

Error monitoring via Sentry runs only when something breaks. Session replays mask all text, inputs, and media — so error reports show structure but never content.

See Privacy for the full policy.

Local development

git clone https://github.com/1436941541/pdf-dark.git
cd pdf-dark
npm install
npm run dev

Open http://localhost:3000.

To enable Sentry locally, copy .env.local.example to .env.local and add your DSN.

Project structure

app/
  page.tsx                       Tool: in-browser dark mode reader
  invert-pdf-colors/             Tool: invert colors & download the new PDF
                                 (was /converter until Aug 2026 — merged)
  blog/                          Guides, one dir per post (see lib/variants.ts)
  about/, privacy/, terms/       Legal / about
  changelog/                     Release history
  sitemap.ts, robots.ts          SEO infrastructure
components/
  drop-zone.tsx                  File input + drag-and-drop
  converter.tsx                  Reader orchestrator (drop zone + viewer)
  downloader.tsx                 Convert & download flow; theme/image defaults
                                 are props so tool pages can start differently
  pdf-viewer.tsx                 Render + dark pass + in-browser reading
lib/
  dark-color.ts                  Color mapping + per-image classifier
  build-dark-pdf.ts              Rebuilds the output PDF
  themes.ts                      Theme background definitions
  variants.ts                    Blog post registry (drives sitemap + cross-links)
  site.ts                        Canonical URL helper

Contributing

Issues and PRs welcome — especially:

  • Edge cases that break the algorithm (weird embedded fonts, scanned PDFs)
  • New theme presets
  • Performance improvements for large PDFs (>50 MB)

For substantial features, please open an issue first to discuss the approach.

License

MIT

Contact

hello@pdfdark.org

No installation packages available.

Remote