Skip to content

About

A modern Windows desktop application for inverting the colours of PDF documents

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PDF Color Inverter

A modern Windows desktop application for inverting PDF colours, with batch conversion, live preview, drag-and-drop, and optional English + Malayalam OCR.

PDF Color Inverter

Why Use PDF Color Inverter?

PDF Color Inverter is useful in a few practical situations:

  • Dark-mode reading: Invert a white-background PDF to create a dark-background copy that is easier to read in low light.
  • Printing: Invert a dark or black-background PDF to create a white-background copy that uses less ink or toner.
  • Accessibility and personal preference: Some documents are simply more comfortable to read with inverted colours, depending on the display and lighting.

Version

1.1.0

Processing modes

Mode Best for What happens
Keep text (vector) Normal digital PDFs Adds a Difference-blend layer to each page. Colours are inverted while text, links, and vector graphics stay intact. Output files stay small.
Rasterize Scanned PDFs, maximum viewer compatibility, OCR Renders every page at the chosen DPI, inverts the bitmap, and rebuilds the PDF. Output is larger and text becomes part of the image (unless OCR is enabled).

OCR is available in Rasterize mode only. It adds invisible, searchable text on top of the inverted pages.

Features

  • Vector-preserving inversion that keeps text selectable and links working
  • Rasterized inversion for scanned documents and maximum compatibility
  • Batch conversion of multiple PDFs
  • Add individual files or an entire folder
  • Native Windows drag-and-drop, including dropped folders
  • Live inverted page preview with page navigation
  • Per-file progress, status, and a working cancel button
  • Adjustable rendering quality from 100–300 DPI
  • Optional English + Malayalam OCR with searchable text
  • Bundled Malayalam Unicode font and Tesseract runtime in the Windows build
  • Output collision handling and an optional replace-existing switch
  • Settings and window size saved between launches
  • Light, dark, and system appearance modes
  • Keyboard shortcuts
  • Standalone Windows executable with version metadata

OCR

OCR uses Tesseract with:

  • English: eng
  • Malayalam: mal
  • Font: Noto Sans Malayalam (bundled), with Nirmala UI as a source-mode fallback

The Windows build script downloads and validates the required OCR language data and font before creating the executable. OCR text is inserted invisibly so the inverted pages stay searchable and selectable.

Requirements

For building from source:

  • Windows 10 or 11
  • Normal CPython 3.13
  • Internet access during the first build
  • Tesseract OCR, or WinGet so the build script can install it

Important: use normal CPython 3.13. Do not use the Python 3.14 free-threaded build (3.14t).

For OCR when running from source without a build:

  • Tesseract eng and mal language data
  • NotoSansMalayalam-Regular.ttf in runtime\fonts\, or the Windows Nirmala UI font

Build the Windows EXE

  1. Clone the repository.
  2. Open Command Prompt in the project directory.
  3. Run:
build_windows.bat

The finished executable is created at:

dist\PDFColorInverter.exe

The build script automatically:

  1. Creates a Python 3.13 virtual environment.
  2. Installs the Python dependencies.
  3. Finds or installs Tesseract OCR.
  4. Downloads the English and Malayalam Tesseract models.
  5. Downloads the Noto Sans Malayalam font.
  6. Validates the downloaded runtime files.
  7. Builds a standalone one-file Windows executable with version metadata.

Run from Source

Prepare the environment once with build_windows.bat, then run:

run_windows.bat

Or launch the application directly:

.venv\Scripts\python.exe app.py

To install only the Python dependencies:

py -3.13 -m venv .venv
.venv\Scripts\python.exe -m pip install -r requirements.txt

Usage

  1. Add PDFs with Add PDF files, Add folder, or by dragging them into the window.
  2. Click a file in the queue to preview the inverted first page. Use the arrow buttons to change pages.
  3. Choose Keep text or Rasterize.
  4. Adjust the output folder, filename suffix, and replace-existing option if needed.
  5. Click Invert queued PDFs. The same button becomes Cancel conversion while a batch is running.
  6. Use the arrow button beside the output folder to open the results.

Keyboard shortcuts

Shortcut Action
Ctrl+O Add PDF files
Ctrl+Shift+O Add a folder
Ctrl+Enter Start or cancel conversion
Ctrl+L Clear the queue
Page Up / Page Down Previous / next preview page
Esc Cancel a running conversion

Output

If no output folder is selected, each source PDF gets an Inverted folder beside it. The default filename suffix is:

_inverted

With Replace existing output files enabled, an existing output is replaced. With it disabled, a unique name such as report_inverted (1).pdf is created instead.

Files are written to a temporary file and moved into place, so a cancelled or failed conversion does not leave a half-written PDF behind.

Notes and limitations

  • Keep text mode uses the PDF Difference blend mode. It preserves text, links, and vector content, but annotations and form-field appearances are not recoloured. If a document relies heavily on annotations, use Rasterize.
  • Rasterize mode flattens the page. Text is no longer selectable unless OCR is enabled. Higher DPI values produce larger files.
  • Password-protected PDFs are reported clearly but must be unlocked before conversion.
  • OCR adds an invisible text layer; it does not change the visible inverted image.

Troubleshooting

OCR is unavailable

Run build_windows.bat to bundle Tesseract and both language models. If you already have Tesseract, make sure eng.traineddata and mal.traineddata are in its tessdata folder. You can also set TESSERACT_CMD to the full path of tesseract.exe and TESSDATA_PREFIX to the tessdata folder.

Output files are very large

Use Keep text mode. If you need rasterization, lower the DPI from 300 to 150–200.

Drag-and-drop does not work

Use Add PDF files instead. Native drag-and-drop is Windows-only and can be blocked by some remote-desktop or security tools.

Where are the logs?

%LOCALAPPDATA%\PDFColorInverter\app.log

Settings are stored at:

%APPDATA%\PDFColorInverter\settings.json

Project structure

PDF-Color-Inverter/
├── app.py                     Entry point, logging, DPI awareness
├── pdf_color_inverter/
│   ├── __init__.py            App metadata and bundled-resource paths
│   ├── core.py                Vector/raster conversion and OCR engine
│   ├── dnd.py                 Native Windows drag-and-drop
│   ├── settings.py            Persisted user settings
│   └── ui.py                  CustomTkinter interface
├── tests/
│   ├── test_core.py
│   ├── test_metadata.py
│   └── test_settings.py
├── packaging/
│   └── version_info.txt       Windows EXE version metadata
├── docs/
│   └── screenshot.png
├── build_windows.bat
├── run_windows.bat
├── requirements.txt
├── requirements-dev.txt
├── pyproject.toml             Pytest and Ruff configuration
├── README.md
├── CHANGELOG.md
├── .gitattributes
└── .gitignore

The Tesseract runtime and Malayalam font are generated locally by the build script and are intentionally excluded from Git.

Development

Install the development dependencies and run the tests:

.venv\Scripts\python.exe -m pip install -r requirements-dev.txt
.venv\Scripts\python.exe -m pytest

License

This project is licensed under the MIT License.

See LICENSE for the full license text.

Author

Adithya S

GitHub: adithya-s-119

About

A modern Windows desktop application for inverting the colours of PDF documents

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages