This repository contains a simple Python script to combine PDFs and images from a folder into a single PDF document.
- Python 3.10+
- PyPDF2
- Pillow
- Loguru
- Coverage.py
- genbadge (for local badge generation)
- (Optional) Create and activate a virtual environment:
python3 -m venv env source env/bin/activate - Install dependencies:
pip install -r requirements.txt
Run the script from the command line, specifying the folder to combine and the output file name:
python combine_files.py --folder /path/to/folder --output output.pdf--folder: Path to the folder containing PDFs and images to combine (sorted by name)--output: Name of the combined output PDF file (defaults tocombined.pdf)
If you omit the flags, the script will prompt you for both values.
If your path contains spaces, wrap it in quotes:
python combine_files.py --folder "/my/path/contains spaces/subdir" --output receipts.pdfThis project uses Coverage.py to measure test coverage. The configuration enforces a minimum of 90%. Generate the local badge after running coverage:
python -m coverage run -m unittest -v
python -m coverage xml
genbadge coverage -i coverage.xml -o badges/coverage.svgThe badge is stored in badges/coverage.svg and referenced directly in the README.
The script uses Loguru for logging. By default it logs at INFO level, including:
- Per-file processing time
- Total run time
- Skipped files (non-files or unsupported types)
MIT