name: pptx description: >- Presentation creation, editing, and analysis. 當需要 to work with 簡報s (.pptx files) for: (1) Creating new 簡報s, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other 簡報 tasks trigger: when_needed language: zh-TW adapted_from: openskills/pptx version: 1.0.0-antigravity original_license: Proprietary. LICENSE.txt has complete terms
PPTX 處理指南
技能版本: v1.0 (Antigravity 適配版)
原始來源: openskills/pptx
語言: 繁體中文
概述
Presentation creation, editing, and analysis. 當需要 to work with 簡報s (.pptx files) for: (1) Creating new 簡報s, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other 簡報 tasks
PPTX creation, editing, and analysis
使用情境
此技能適用於以下情況:
- 用戶明確要求相關功能時
- 任務需要專業領域知識時
- 需要遵循特定工作流程時
概述
A user may ask you to create, edit, or analyze the contents of a .pptx file. A .pptx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.
Reading and analyzing content
Text extraction
If you just need to read the text contents of a presentation, you should convert the document to markdown:
# Convert document to markdown
python -m markitdown path-to-file.pptx
詳細內容請參閱:[example_1.txt](examples/example_1.txt)
* **Using the thumbnail grid**: Reference the visual thumbnails to identify:
- Layout patterns (title slides, content layouts, section dividers)
- Image placeholder locations and counts
- Design consistency across slide groups
- Visual hierarchy and structure
* This inventory file is REQUIRED for selecting appropriate templates in the next step
3. **Create presentation outline based on template inventory**:
* Review available templates from step 2.
* Choose an intro or title template for the first slide. This should be one of the first templates.
* Choose safe, text-based layouts for the other slides.
* **CRITICAL: Match layout structure to actual content**:
- Single-column layouts: Use for unified narrative or single topic
- Two-column layouts: Use ONLY when you have exactly 2 distinct items/concepts
- Three-column layouts: Use ONLY when you have exactly 3 distinct items/concepts
- Image + text layouts: Use ONLY when you have actual images to insert
- Quote layouts: Use ONLY for actual quotes from people (with attribution), never for emphasis
- Never use layouts with more placeholders than you have content
- If you have 2 items, don't force them into a 3-column layout
- If you have 4+ items, consider breaking into multiple slides or using a list format
* Count your actual content pieces BEFORE selecting the layout
* Verify each placeholder in the chosen layout will be filled with meaningful content
* Select one option representing the **best** layout for each content section.
* Save `outline.md` with content AND template mapping that leverages available designs
* Example template mapping:
詳細內容請參閱:[example_2.txt](examples/example_2.txt)
4. **Duplicate, reorder, and delete slides using `rearrange.py`**:
* Use the `scripts/rearrange.py` script to create a new presentation with slides in the desired order:
```bash
python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52
詳細內容請參閱:[example_3.txt](examples/example_3.txt)
* **Read text-inventory.json**: Read the entire text-inventory.json file to understand all shapes and their properties. **NEVER set any range limits when reading this file.**
* The inventory JSON structure:
詳細內容請參閱:[example_1.txt](resources/example_1.txt)
* Key features:
- **Slides**: Named as "slide-0", "slide-1", etc.
- **Shapes**: Ordered by visual position (top-to-bottom, left-to-right) as "shape-0", "shape-1", etc.
- **Placeholder types**: TITLE, CENTER_TITLE, SUBTITLE, BODY, OBJECT, or null
- **Default font size**: `default_font_size` in points extracted from layout placeholders (when available)
- **Slide numbers are filtered**: Shapes with SLIDE_NUMBER placeholder type are automatically excluded from inventory
- **Bullets**: When `bullet: true`, `level` is always included (even if 0)
- **Spacing**: `space_before`, `space_after`, and `line_spacing` in points (only included when set)
- **Colors**: `color` for RGB (e.g., "FF0000"), `theme_color` for theme colors (e.g., "DARK_1")
- **Properties**: Only non-default values are included in the output
6. **Generate replacement text and save the data to a JSON file**
Based on the text inventory from the previous step:
- **CRITICAL**: First verify which shapes exist in the inventory - only reference shapes that are actually present
- **VALIDATION**: The replace.py script will validate that all shapes in your replacement JSON exist in the inventory
- If you reference a non-existent shape, you'll get an error showing available shapes
- If you reference a non-existent slide, you'll get an error indicating the slide doesn't exist
- All validation errors are shown at once before the script exits
- **IMPORTANT**: The replace.py script uses inventory.py internally to identify ALL text shapes
- **AUTOMATIC CLEARING**: ALL text shapes from the inventory will be cleared unless you provide "paragraphs" for them
- Add a "paragraphs" field to shapes that need content (not "replacement_paragraphs")
- Shapes without "paragraphs" in the replacement JSON will have their text cleared automatically
- Paragraphs with bullets will be automatically left aligned. Don't set the `alignment` property on when `"bullet": true`
- Generate appropriate replacement content for placeholder text
- Use shape size to determine appropriate content length
- **CRITICAL**: Include paragraph properties from the original inventory - don't just provide text
- **IMPORTANT**: When bullet: true, do NOT include bullet symbols (•, -, *) in text - they're added automatically
- **ESSENTIAL FORMATTING RULES**:
- Headers/titles should typically have `"bold": true`
- List items should have `"bullet": true, "level": 0` (level is required when bullet is true)
- Preserve any alignment properties (e.g., `"alignment": "CENTER"` for centered text)
- Include font properties when different from default (e.g., `"font_size": 14.0`, `"font_name": "Lora"`)
- Colors: Use `"color": "FF0000"` for RGB or `"theme_color": "DARK_1"` for theme colors
- The replacement script expects **properly formatted paragraphs**, not just text strings
- **Overlapping shapes**: Prefer shapes with larger default_font_size or more appropriate placeholder_type
- Save the updated inventory with replacements to `replacement-text.json`
- **WARNING**: Different template layouts have different shape counts - always check the actual inventory before creating replacements
Example paragraphs field showing proper formatting:
詳細內容請參閱:[example_2.txt](resources/example_2.txt)
**Shapes not listed in the replacement JSON are automatically cleared**:
詳細內容請參閱:[example_3.txt](resources/example_3.txt)
**Common formatting patterns for presentations**:
- Title slides: Bold text, sometimes centered
- Section headers within slides: Bold text
- Bullet lists: Each item needs `"bullet": true, "level": 0`
- Body text: Usually no special properties needed
- Quotes: May have special alignment or font properties
7. **Apply replacements using the `replace.py` script**
```bash
python scripts/replace.py working.pptx replacement-text.json output.pptx
詳細內容請參閱:[example_4.txt](examples/example_4.txt)
ERROR: Invalid shapes in replacement JSON:
- Shape 'shape-99' not found on 'slide-0'. Available shapes: shape-0, shape-1, shape-4
- Slide 'slide-999' not found in inventory
ERROR: Replacement text made overflow worse in these shapes:
- slide-0/shape-2: overflow worsened by 1.25" (was 0.00", now 1.25")
詳細內容請參閱:[example_5.txt](examples/example_5.txt)
**Features**:
- Creates: `thumbnails.jpg` (or `thumbnails-1.jpg`, `thumbnails-2.jpg`, etc. for large decks)
- Default: 5 columns, max 30 slides per grid (5×6)
- Custom prefix: `python scripts/thumbnail.py template.pptx my-grid`
- 注意: The output prefix should include the path if you want output in a specific directory (e.g., `workspace/my-grid`)
- Adjust columns: `--cols 4` (range: 3-6, affects slides per grid)
- Grid limits: 3 cols = 12 slides/grid, 4 cols = 20, 5 cols = 30, 6 cols = 42
- Slides are zero-indexed (Slide 0, Slide 1, etc.)
**Use cases**:
- Template analysis: Quickly understand slide layouts and design patterns
- Content review: Visual overview of entire presentation
- Navigation reference: Find specific slides by their visual appearance
- Quality check: Verify all slides are properly formatted
**範例**:
```bash
# Basic usage
python scripts/thumbnail.py presentation.pptx
# Combine options: custom name, columns
python scripts/thumbnail.py template.pptx analysis --cols 4
詳細內容請參閱:[example_6.txt](examples/example_6.txt)
2. **Convert PDF pages to JPEG images**:
```bash
pdftoppm -jpeg -r 150 template.pdf slide
詳細內容請參閱:[example_7.txt](examples/example_7.txt)
## Code Style Guidelines
**IMPORTANT**: When generating code for PPTX operations:
- Write concise code
- Avoid verbose variable names and redundant operations
- Avoid unnecessary print statements
## Dependencies
Required dependencies (should already be installed):
- **markitdown**: `pip install "markitdown[pptx]"` (for text extraction from presentations)
- **pptxgenjs**: `npm install -g pptxgenjs` (for creating presentations via html2pptx)
- **playwright**: `npm install -g playwright` (for HTML rendering in html2pptx)
- **react-icons**: `npm install -g react-icons react react-dom` (for icons)
- **sharp**: `npm install -g sharp` (for SVG rasterization and image processing)
- **LibreOffice**: `sudo apt-get install libreoffice` (for PDF conversion)
- **Poppler**: `sudo apt-get install poppler-utils` (for pdftoppm to convert PDF to images)
- **defusedxml**: `pip install defusedxml` (for secure XML parsing)
---
## 專案整合
此技能已適配 Antigravity 系統:
- 遵循 `skills/_base/coding_style.md` 編碼規範
- 與 `skills/_base/architecture.md` 架構模式一致
- 符合 Constitution v3.1 語言規範 (繁體中文)
### 相關技能
可搭配以下技能使用:
- `systematic-debugging` - 系統化除錯
- `verification-before-completion` - 完成前驗證