OpenSource Project | Open for Contribution
A high-performance PDF flattening and compression utility designed to prevent printer memory overflow and optimize print spooling.
Python 3.8+ • MIT License • Open Source
The Print Spool Optimizer is a Python utility designed to flatten and compress PDF documents. By converting complex vector graphics, fonts, and layers into standard grayscale images, it reduces the processing load on printer hardware. This prevents memory overflow and ensures rapid print spooling for large documents.
## Prerequisites * Python 3.8 or higherTo prevent dependency conflicts with your system's global Python installation, you must run this tool within an isolated virtual environment.
Navigate to the root directory of this project in your terminal and execute the following command to create a virtual environment named venv:
python3 -m venv venvYou must activate the environment before installing dependencies or executing the script. Your terminal prompt will change to indicate the environment is active.
source venv/bin/activate
venv\Scripts\activate.bat
venv\Scripts\Activate.ps1
Once the virtual environment is active, install the required packages using the provided requirements file:
pip install -r requirements.txt
python spool_optimizer.py -i input_file_name.pdf -o output_file_name.pdf
| Flag | Default | Description |
|---|---|---|
-i / --input |
(required) | Path to the input PDF file |
-o / --output |
(required) | Path for the output PDF file |
--dpi |
100 |
Rasterization resolution (72–300) |
--workers |
0 |
Worker processes for parallel rendering. 0 = all CPU cores. 1 = sequential (no multiprocessing) |
Example — use 4 workers for a large PDF:
python spool_optimizer.py -i large_doc.pdf -o output.pdf --dpi 150 --workers 4
When you are finished using the tool, you can exit the virtual environment by running:
deactivate
Run the app in a fully isolated container — no Python or venv setup required.
docker compose up --buildThe web UI will be available at : http://localhost:5000.
# Build the image
docker build -t pdf-spool-optimizer .
# Run the container
docker run -p 5000:5000 pdf-spool-optimizerdocker compose down| Variable | Default | Description |
|---|---|---|
FLASK_ENV |
production |
Set to development to enable debug mode |
FLASK_HOST |
127.0.0.1 |
Bind address (use 0.0.0.0 in containers) |
FLASK_PORT |
5000 |
Port the dev server listens on |
Author: Mathi Yuvarajan T.K
Contributors :
- ANISH KARTHIC

