😫 The Pain Point
You have 50 Word documents that need to be converted to PDF for archiving or distribution. Opening each in Word and “Save as PDF” x 50 is tedious.
🚀 Agentic Solution
A Batch Word-to-PDF Converter that processes entire folders.
Key Features:
- Accurate Conversion: Preserves formatting, fonts, images.
- Batch Processing: Convert entire folders recursively.
- Original Preservation: Keeps Word files, creates PDFs alongside.
⚔️ Phase 1: Commander (Quick Fix)
For quick conversion.
Prompt:
“I have a folder
documentswith Word files (.docx, .doc). Write a Python script to:
- Convert: All Word files to PDF.
- Output: Save PDFs in same folder (or
pdf_output/subfolder).- Recursive: Process subfolders if
--recursiveflag.Print progress (e.g., ‘Converted 1/50: report.docx’). Handle corrupt files (skip with warning).
Note: On Windows, use
docx2pdf(requires MS Word). On Mac/Linux, use LibreOffice headless.”
Result: PDF versions of all documents.
🏗️ Phase 2: Architect (Permanent Tool)
For Office Admins.
Engineering Prompt:
**Role:** Python GUI Developer (PyQt6 Specialist)
**Task:** Create "Word to PDF Batch" Desktop App
**Objective:** A reliable batch converter using native Office APIs or cross-platform libraries.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Engine: docx2pdf (Windows/Mac with Word installed)
* Packaging: PyInstaller
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* **Input:** Folder or Drag & Drop DOCX files.
* **Options:** Toggle "Recursive Scan".
* **Status:** "Converting 10/50..."
* **Action:** "Start Conversion".
2. **Core Logic:**
* **Windows:** Dispatch `docx2pdf` (COM automation).
* **Fallback:** `subprocess` call to LibreOffice --headless.
* **Threading:** Conversion is slow and blocking; must use threads to update UI.
3. **Deliverables:**
* `main.py`: Complete source code.
* `requirements.txt`: Dependencies.
* **Build Instructions:**
* Windows: `pyinstaller --onefile --noconsole main.py`
* macOS: `pyinstaller --windowed --noconsole main.py`
🧠 Prompt Decoding
- docx2pdf on Windows: Uses COM automation to control Microsoft Word.
- LibreOffice on Mac/Linux: Free alternative that can convert via command line.
🛠️ Instructions
- Windows: Install
pip install docx2pdf - Mac/Linux: Install LibreOffice.
- Copy Prompt → Run.