Metadata-Version: 2.4
Name: pdf-invert
Version: 0.1.0
Summary: Vector-preserving dark-mode (colour inversion) for PDFs
Keywords: pdf,dark-mode,invert,colours,accessibility,cli
Author: rian-dolphin
Author-email: rian-dolphin <rdolphin98@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: Topic :: Utilities
Requires-Dist: pikepdf>=10.10.0
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/rian-dolphin/pdf-invert
Project-URL: Repository, https://github.com/rian-dolphin/pdf-invert
Project-URL: Issues, https://github.com/rian-dolphin/pdf-invert/issues
Description-Content-Type: text/markdown

# pdf-invert

Convert a PDF into a dark-mode version by inverting its colours — **without
rasterizing**. Text stays selectable and searchable, vector graphics stay
vector, and the file stays roughly the same size.

```console
$ uvx pdf-invert paper.pdf
Wrote paper-dark.pdf
```

## Usage

```console
pdf-invert INPUT [-o OUTPUT] [--invert-images] [--linearize] [-q]
```

* `INPUT` — the source PDF.
* `-o, --output` — destination (default: `<name>-dark.pdf` beside the input).
* `--invert-images` — also invert raster images. Off by default so photos,
  figures, and logos don't become negatives.
* `--linearize` — linearize output for faster web viewing.
* `-q, --quiet` — suppress warnings.

## How it works

For every colour-setting operator in every content stream (page bodies, form
XObjects, tiling patterns, Type3 glyphs, annotation appearances), each channel
value `v` is replaced with `1 - v`, and a black backdrop is placed behind the
page. Because only colours change, the text and vector geometry are untouched.

A few deliberate choices make this robust on real documents — establishing white
as the default colour (so text drawn without an explicit colour doesn't vanish
on the black backdrop), tracking the current colourspace so `sc`/`scn` are only
inverted when that's meaningful, visiting shared objects once, and never
entering soft masks. See [KNOWN_LIMITATIONS.md](KNOWN_LIMITATIONS.md) for what's
out of scope.

## Why not Ghostscript / rasterizing?

Ghostscript's `setcolortransfer` inverts at the render pipeline and is excellent,
but it needs a system binary and inverts *everything*, including images. A
rasterize-and-invert approach loses selectable text and bloats file size (often
20×). `pdf-invert` is pure Python (`pikepdf`), installs anywhere `uv`/`pip`
reaches, keeps text, and lets you preserve images.

## Development

```console
uv run pdf-invert some.pdf      # run from source
```
