PDF 转高清 PPT,版式零失真
简介
将PDF页面转为高清图像后嵌入PPT,完美保留视觉排版,适合扫描件、设计稿等复杂版式文档的批量转换。
原始描述
Convert PDF files to PowerPoint presentations via intermediate image rendering. Created collaboratively with 贾维斯 (AI assistant) by Hugo. Use when working wit...
通过你的 Agent 添加
安装目录:pdf-to-ppt/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: pdf-to-ppt
description: |
Convert PDF files to PowerPoint presentations via intermediate image rendering.
Created collaboratively with 贾维斯 (AI assistant) by Hugo.
Use when working with PDF documents that are primarily visual (e.g., design drawings, presentations scanned to PDF, etc.) and preserves the visual layout faithfully.
PDF to PPT Conversion Skill
This skill converts PDF files into PowerPoint presentations by first rendering each PDF page as a high-quality image, then assembling those images into a PPT where each image fills a slide. This approach works well for PDFs that are primarily visual (e.g., design drawings, presentations scanned to PDF, etc.) and preserves the visual layout faithfully.
When to Use
Use this skill when you need to:
- Convert a PDF document into an editable PowerPoint presentation.
- Preserve the exact visual layout of each PDF page (text, images, vectors) as slide backgrounds.
- Work with PDFs that are not easily editable via direct text extraction (e.g., complex layouts, designer files).
- Batch-convert multiple PDFs to PPT format.
Core Rules
1. Input PDF Requirements
- The PDF should be text-based or vector-based for best results. Scanned PDFs will be converted as images (which is still valid for this skill).
- Ensure the PDF is not password-protected, or provide the password via environment variable if supported.
2. Image Rendering Quality
- The skill renders PDF pages to images using a configurable zoom factor (default 2.0, which yields ~144 DPI from default 72 DPI).
- Higher zoom values increase image quality and file size but improve text readability in the resulting PPT.
- For text-heavy PDFs where you need selectable text in PPT, consider direct PDF→PPT conversion tools (like LibreOffice) instead.
3. Output PPT Characteristics
- Each PDF page becomes one slide.
- Slide size defaults to 16:9 (width=13.33in, height=7.5in) but can be customized.
- Images are stretched to fill the slide; aspect ratio is not locked (to ensure full coverage). If aspect ratio preservation is critical, edit the script to center and crop.
- The generated PPT uses a blank layout for each slide, placing the image as a shape that covers the entire slide.
4. Dependencies
- Python packages:
PyMuPDF (fitz) and python-pptx.
- These are installed automatically when the skill is first used via the provided install command, or you can install them manually.
Installation
- Each PDF page becomes one slide.
- Slide size defaults to 16:9 (width=13.33in, height=7.5in) but can be customized.
- Images are stretched to fill the slide; aspect ratio is not locked (to ensure full coverage). If aspect ratio preservation is critical, edit the script to center and crop.
- The generated PPT uses a blank layout for each slide, placing the image as a shape that covers the entire slide.
4. Dependencies
- Python packages:
PyMuPDF (fitz) and python-pptx.
- These are installed automatically when the skill is first used via the provided install command, or you can install them manually.
Installation
PyMuPDF (fitz) and python-pptx.To install this skill from a local path (after copying to your skills folder), you can use:
clawhub install /path/to/pdf-to-ppt
Or if you have cloned the skill repository:
clawhub install pdf-to-ppt
Usage
Basic Conversion
python3 scripts/pdf_to_ppt.py input.pdf
This will:
- Create an
images/subdirectory next to the input PDF (or use a specified directory). - Render each PDF page to a PNG image in that folder.
- Generate a PPT file with the same base name as the input PDF, appended with
.pptx, in the same directory as the input.
Advanced Options
python3 scripts/pdf_to_ppt.py input.pdf \
--img-dir /path/to/images \
--output output.pptx \
--zoom 3.0 \
--slide-width-in 16 \
--slide-height-in 9 \
--format png
Arguments:
python3 scripts/pdf_to_ppt.py input.pdf \
--img-dir /path/to/images \
--output output.pptx \
--zoom 3.0 \
--slide-width-in 16 \
--slide-height-in 9 \
--format png
input.pdf: Path to the source PDF file (required).--img-dir DIR: Directory to store intermediate images. If not provided, defaults to<pdf_dir>/images/.--output PPTX: Path for the output PPT file. If not provided, defaults to<pdf_basename>.pptxin the same directory as input PDF.--zoom ZOOM: Zoom factor for rendering (default 2.0). Higher = higher DPI.--slide-width-in INCHES: Width of slides in inches (default 13.33 for 16:9 at 7.5in height).--slide-height-in INCHES: Height of slides in inches (default 7.5).--format {png,jpg}: Image format for intermediates (default png).
Example: Convert with Custom Settings
python3 scripts/pdf_to_ppt.py report.pdf \
--img-dir ./tmp/imgs \
--output ./presentation.pptx \
--zoom 2.5 \
--format jpg
Workflow Tips
- Check Image Quality: After conversion, open the generated PPT and review a few slides. If text appears blurry, increase
--zoom.
- File Size: Higher zoom and PNG format increase both image and final PPT size. Use JPG for smaller files if slight compression artifacts are acceptable.
- Post-Processing: The PPT is fully editable in PowerPoint. You can:
- Add text boxes, shapes, or annotations over the image backgrounds.
- Replace images with higher-quality versions if needed.
- Extract individual images via “Save as Picture” if required.
- Batch Processing: Wrap the script in a loop for multiple PDFs:
for pdf in *.pdf; do
python3 scripts/pdf_to_ppt.py "$pdf"
done
Troubleshooting
- ModuleNotFoundError for fitz or pptx: Ensure dependencies are installed. Run:
pip install --break-system-packages PyMuPDF python-pptx
(Add --break-system-packages if using system Python in a restricted environment.)
- Empty Images: Verify the PDF is not empty and that PyMuPDF can open it. Try opening the PDF in a viewer to confirm it has content.
- Memory Issues: Very large PDFs with high zoom may consume significant RAM. Process in batches or reduce zoom.
Related Skills
python3 scripts/pdf_to_ppt.py report.pdf \
--img-dir ./tmp/imgs \
--output ./presentation.pptx \
--zoom 2.5 \
--format jpg
- Check Image Quality: After conversion, open the generated PPT and review a few slides. If text appears blurry, increase
--zoom. - File Size: Higher zoom and PNG format increase both image and final PPT size. Use JPG for smaller files if slight compression artifacts are acceptable.
- Post-Processing: The PPT is fully editable in PowerPoint. You can:
- Add text boxes, shapes, or annotations over the image backgrounds.
- Replace images with higher-quality versions if needed.
- Extract individual images via “Save as Picture” if required.
- Batch Processing: Wrap the script in a loop for multiple PDFs:
for pdf in *.pdf; do python3 scripts/pdf_to_ppt.py "$pdf" done
Troubleshooting
- ModuleNotFoundError for fitz or pptx: Ensure dependencies are installed. Run:
pip install --break-system-packages PyMuPDF python-pptx
(Add --break-system-packages if using system Python in a restricted environment.)
- Empty Images: Verify the PDF is not empty and that PyMuPDF can open it. Try opening the PDF in a viewer to confirm it has content.
- Memory Issues: Very large PDFs with high zoom may consume significant RAM. Process in batches or reduce zoom.
Related Skills
pip install --break-system-packages PyMuPDF python-pptx
(Add --break-system-packages if using system Python in a restricted environment.)Consider combining with:
pdf-tools— for extracting text, merging, splitting PDFs before conversion.powerpoint-pptx— for best practices on editing and styling the resulting PPT.images— if you need to process the intermediate images further.
Feedback
If you find this skill useful, consider starring it on ClawHub: clawhub star pdf-to-ppt
For issues or enhancements, please refer to the skill’s source repository.
This skill was created to automate PDF → image → PPT conversion for visual-rich documents.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。