This Python script automates the process of inverting colors in PDF documents giving a Dark Mode feeling. Works great for kindle like device that don't offer a dark mode. It also keeps your folder structure for convenience
- Color Inversion: Efficiently inverts colors of PDF pages.
- Text and Image Detection: Differentiates between text-heavy and image-heavy pages for optimal processing.
- Multi-threaded Processing: Uses concurrent threads for faster processing of multiple PDF files.
- Automatic PDF Conversion: Converts processed pages back into PDF format without converting everything into images first, saving space.
- Python 3.6+
- PyMuPDF (
fitz) library - Pillow (
PIL) library - PyPDF2 library
- Clone the repository:
git clone https://github.com/Deadlydav/bulkpdfcolorinverter.git
- Install the required libraries:
pip install PyMuPDF pillow PyPDF2
- Modify the input_folder and output_folder variables at the end of the bulkpdfinverter.py to specify your input PDF directory and desired output directory.
# Define input and output directories
input_folder = '/path/to/your/input/folder'
output_folder = '/path/to/your/output/folder'
- Run the script:
python3 invert_pdf_colors.py
- Inverted PDFs will be saved in the
outputfolder structure.
Adjust the following parameters in invert_pdf_colors.py as needed:
dpi: DPI resolution for image conversion.contrast_factor: Adjusts contrast enhancement for image-heavy pages.
This project is licensed under the MIT License. See the LICENSE file for details.
Pull requests are welcome.