Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Compressor

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.

Features

  • 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

Screenshot

┌──────────────────────────────────────────────────────┐
│ 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]                            │
└──────────────────────────────────────────────────────┘

Requirements

  • Python 3.8+
  • PyMuPDF (fitz)

Quick Start

# Install dependencies
pip install PyMuPDF

# Run the app
python pdf_compressor_app.py

Build Standalone EXE

# Install PyInstaller
pip install pyinstaller

# Build (or just run build_exe.bat)
pyinstaller --onefile --windowed --name "PDF压缩工具" pdf_compressor_app.py

The EXE will be in dist/PDF压缩工具.exe (~48 MB, no Python required).

How It Works

  1. Lossless pass — first tries garbage=4, deflate=True (no quality loss)
  2. Image recompression — for scanned/image-heavy PDFs: renders each page, re-encodes as JPEG with quality search
  3. Resolution scaling — if target is still not met, scales down page resolution
  4. Target allocation — in total-size mode, distributes the target proportionally by original file size

License

MIT

About

PDF compression by directory level

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages