π« 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 Tool Developer
**Task:** Create a "Word to PDF Converter".
**Requirements:**
1. **GUI:**
* Select folder.
* Checkbox: Recursive.
* Output location: Same folder / Separate folder.
* Progress bar.
2. **Logic:**
* Detect platform (Windows/Mac/Linux).
* Use appropriate conversion method.
* Handle permission errors.
* Preserve folder structure in output.
3. **Deliverables:**
* `word_to_pdf.py`
* `run.bat`, `run.sh`
* `requirements.txt`
π§ 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.