PDF 转 PPTX/Word 转换器 - 将 PDF 文件转换为 PowerPoint 或 Word 格式,支持文件大小限制。
bash
pip3 install --break-system-packages pdf2image python-pptx pdf2docx Pillow
注意: pdf2image 需要系统安装 poppler:
bash
# macOS
brew install poppler
# Ubuntu/Debian
sudo apt-get install poppler-utils
bash
# 转换为 PPTX(默认)
python3 skills/pdf-converter/scripts/convert.py /path/to/file.pdf
# 转换为 Word
python3 skills/pdf-converter/scripts/convert.py /path/to/file.pdf --format docx
# 指定最大文件大小(MB)
python3 skills/pdf-converter/scripts/convert.py /path/to/file.pdf --max-size 30
# 指定输出路径
python3 skills/pdf-converter/scripts/convert.py /path/to/file.pdf --output /path/to/output.pptx
bash
# 调整 DPI(影响质量和大小,默认 150)
python3 skills/pdf-converter/scripts/convert.py file.pdf --dpi 200
# 调整图片质量(1-100,默认 85)
python3 skills/pdf-converter/scripts/convert.py file.pdf --quality 75
# 批量转换整个目录
python3 skills/pdf-converter/scripts/convert.py /path/to/pdfs/ --batch
# 静默模式(仅输出最终结果)
python3 skills/pdf-converter/scripts/convert.py file.pdf --quiet
参数说明默认值inputPDF 文件路径或目录(批量模式)必需--format输出格式: pptx 或 docx``pptx``--max-size最大文件大小(MB),超过会尝试压缩30``--output输出文件路径与 PDF 同目录--dpi渲染 DPI(影响质量和大小)150``--qualityJPEG 图片质量(1-100)85``--batch批量转换目录中的所有 PDFFalse``--quiet静默模式,仅输出结果False
bash
python3 skills/pdf-converter/scripts/convert.py "/Users/admin/Desktop/中金公司 2026 年度公关服务响应方案 -0318.pdf"
输出:
text
📄 源文件:中金公司 2026 年度公关服务响应方案 -0318.pdf
📊 源大小:21.91 MB
🔄 开始转换...
✓ 共 118 页
📊 创建幻灯片...
已处理 20/118 页
已处理 40/118 页
...
✅ 转换成功!
📊 输出大小:22.51 MB
✓ 大小限制:≤30 MB - ✅ 符合
📍 保存位置:/Users/admin/Desktop/中金公司 2026 年度公关服务响应方案 -0318.pptx
bash
python3 skills/pdf-converter/scripts/convert.py file.pdf --format docx --max-size 20
bash
python3 skills/pdf-converter/scripts/convert.py /path/to/pdfs/ --batch --format pptx
PDF 大小页数DPI转换时间PPTX 大小5 MB2015015 秒8 MB20 MB10015060 秒20 MB50 MB200150120 秒45 MB
pdf2image 报错 "unable to get page count"#原因: 缺少 poppler 工具
解决:
bash
# macOS
brew install poppler
# Ubuntu/Debian
sudo apt-get install poppler-utils
解决:
--dpi 100--quality 60--max-size 30解决: 使用完整路径,确保文件系统支持 UTF-8
text
skills/pdf-converter/
├── SKILL.md # 本文件
├── scripts/
│ └── convert.py # 转换脚本
└── README.md # 详细文档(可选)