A Windows GUI application for batch compressing PDF files by directory level. Compress all PDFs in a folder to a target total size or reduce them to a fraction of their original size.
- Directory-level scanning — recursively find all PDFs in a folder tree
- Checkbox selection — choose which PDFs to compress
- Two compression modes:
- Target total size — all selected PDFs compressed to fit within X MB
- Fraction mode — each PDF reduced to 1/N of its original size (1/2, 1/4, 1/8…)
- Two output modes:
- Save to a subfolder (keeps originals intact)
- Replace originals directly
- Progress bar with cancel support
- Remembers settings between sessions
┌──────────────────────────────────────────────────────┐
│ PDF Compressor v1.0 │
├──────────────────────────────────────────────────────┤
│ Directory │
│ Root: [________________________] [Browse...] [Scan] │
├──────────────────────────────────────────────────────┤
│ PDF Files │
│ ┌────────────────────────────────────────────────┐ │
│ │ [v] file1.pdf 2.38 MB 1p [IMG] │ │
│ │ [v] file2.pdf 1.93 MB 1p [IMG] │ │
│ │ ... │ │
│ └────────────────────────────────────────────────┘ │
│ Found 14 PDF files | Total: 12.67 MB │
├──────────────────────────────────────────────────────┤
│ Compression Mode │ Output │
│ ○ Target total: [__] MB │ ○ Save to: [compressed__] │
│ ○ Reduce to 1/[4] │ ○ Replace originals │
├──────────────────────────────────────────────────────┤
│ [████████████████░░░░] │
│ Status: Ready │
│ [Start Compression] [Stop] │
└──────────────────────────────────────────────────────┘
- Python 3.8+
- PyMuPDF (fitz)
# Install dependencies
pip install PyMuPDF
# Run the app
python pdf_compressor_app.py# Install PyInstaller
pip install pyinstaller
# Build (or just run build_exe.bat)
pyinstaller --onefile --windowed --name "PDF压缩工具" pdf_compressor_app.pyThe EXE will be in dist/PDF压缩工具.exe (~48 MB, no Python required).
- Lossless pass — first tries
garbage=4, deflate=True(no quality loss) - Image recompression — for scanned/image-heavy PDFs: renders each page, re-encodes as JPEG with quality search
- Resolution scaling — if target is still not met, scales down page resolution
- Target allocation — in total-size mode, distributes the target proportionally by original file size
MIT