A lightweight Python project to generate optimized PDFs from image archives.
It extracts .jpg files from a .7z archive, resizes them to fit an A4 page, and combines them into a single PDF.
- Extract
.jpgimages from.7zarchives - Resize/compress images for smaller PDF size
- Generate full-page PDFs with
fpdf2 - Logging with
loguru - Modern dependency & linting setup with uv
This project uses uv (a fast Python package/dependency manager).
Make sure you have it installed:
pip install uvThen, install dependencies:
uv syncThis will create and manage a .venv automatically.
Run the PDF generator:
uv run main.py(or whatever entrypoint you use — adjust the path accordingly).
The script will:
- Extract images from
input.7zinto the./imagesfolder - Resize them to fit an A4 page (at ~150 DPI)
- Generate
output.pdfin the project root
Run linting and auto-fixes with ruff:
uv run ruff check --fixFormat code:
uv run ruff formatpdf-generator/
├── pyproject.toml # Dependencies & project config
├── README.md # Documentation
├── src/
│ └── pdf_generator.py
├── images/ # Extracted images (generated at runtime)
└── input.7z # Input archive
└── main.py # Main application script
- Python 3.13+
fpdf2for PDF generationPillowfor image resizingpy7zrfor.7zextractionlogurufor loggingrufffor linting & formatting
MIT License — feel free to use and adapt.