🎯 Vấn đề cần giải quyết
PDF 50MB không gửi được qua email (giới hạn 25MB)? Upload lên hệ thống bị reject vì quá lớn? Website load chậm vì PDF nặng?
Pain points:
- File quá lớn để share
- Upload bị timeout
- Storage đầy nhanh
⚖️ So sánh: Trước và Sau
| Tiêu chí | Original | Compressed |
|---|---|---|
| File size | 50MB | 5-10MB |
| Quality | Max | Still readable |
| Email friendly | Không | Có |
💡 Prompt mẫu
Nén file PDF:
INPUT: [file PDF lớn]
COMPRESSION LEVEL:
- Low: giữ chất lượng cao (giảm 30-40%)
- Medium: balanced (giảm 50-60%)
- High: tối ưu size (giảm 70-80%)
OPTIMIZE:
- Downscale images: 150 DPI (đủ cho màn hình)
- Remove metadata: Có
- Flatten forms: Tùy chọn
- Subset fonts: Có
TARGET:
- Max file size: 10MB
- Hoặc compression ratio: 70%
OUTPUT:
- Suffix: _compressed
- Report: before/after size
🏗️ Phase 2: Architect (Permanent Tool)
For IT/Archiving Teams.
Engineering Prompt:
**Role:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create "PDF Optimizer" Desktop App
**Objective:** A compression utility to reduce PDF file size while maintaining readability.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Engine: Ghostscript (via subprocess) or pypdf (limited)
* Packaging: PyInstaller
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* **Input:** File/Folder List.
* **Profile:** Dropdown "Screen (72dpi)", "Ebook (150dpi)", "Print (300dpi)".
* **Stats:** Table showing "Original Size" vs "Compressed Size" (Real-time update).
* **Action:** "Compress All".
2. **Core Logic:**
* Interface with `Ghostscript` binary for high-efficiency compression.
* Alternative: Downsample images using `pikepdf`.
* **Threading:** Compression is CPU intensive; runs in background.
3. **Deliverables:**
* `main.py`: Complete source code.
* `requirements.txt`: Dependencies.
* **Build Instructions:**
* Windows: `pyinstaller --onefile --noconsole main.py`
* macOS: `pyinstaller --windowed --noconsole main.py`
🔧 Tips & Best Practices
What takes space in PDF?
| Content | % Size | Compress? |
|---|---|---|
| Images | 80-90% | Yes, main target |
| Fonts | 5-15% | Subset |
| Text | 1-5% | Already small |
| Metadata | 1% | Remove |
DPI guidelines
| Purpose | DPI |
|---|---|
| Screen only | 72-100 |
| Print home | 150 |
| Print professional | 300 |
Quality presets
- Screen: Smallest, 72dpi, web viewing
- eBook: Small, 150dpi, tablets
- Print: Large, 300dpi, professional
Độ khó: ⭐ Beginner | Thời gian: 3 phút