Pptx

From Wide-Moat/open-computer-use · View interactive version

Pptx is an AI agent skill from the GitHub repository Wide-Moat/open-computer-use. Presentation creation, editing, and analysis. When Assistant needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

How to use this skill

Skill file

PPTX creation, editing, and analysis

Overview

Create, edit, or analyze the contents of .pptx files when requested. A .pptx file is essentially a ZIP archive containing XML files and other resources. Different tools and workflows are available for different tasks.

Reading and analyzing content

Text extraction

To read just the text content of a presentation, convert the document to markdown:

# Convert document to markdown
python -m markitdown path-to-file.pptx

Raw XML access

Use raw XML access for: comments, speaker notes, slide layouts, animations, design elements, and complex formatting. To access these features, unpack a presentation and read its raw XML contents.

Unpacking a file

python /mnt/skills/public/pptx/ooxml/scripts/unpack.py <office_file> <output_dir>

Key file structures
Typography and color extraction

To emulate example designs, analyze the presentation's typography and colors first using the methods below:

  1. Read theme file: Check ppt/theme/theme1.xml for colors (<a:clrScheme>) and fonts (<a:fontScheme>)
  2. Sample slide content: Examine ppt/slides/slide1.xml for actual font usage (<a:rPr>) and colors
  3. Search for patterns: Use grep to find color (<a:solidFill>, <a:srgbClr>) and font references across all XML files

Creating a new PowerPoint presentation **without a template**

When creating a new PowerPoint presentation from scratch, use the html2pptx workflow to convert HTML slides to PowerPoint with accurate positioning.

IMPORTANT: html2pptx is a JavaScript LIBRARY, not a CLI tool. You MUST create a .js script with import { html2pptx } and run it with node script.js. Do NOT run html2pptx, npx html2pptx, or create config.json files — html2pptx has no CLI interface.

Workflow

  1. MANDATORY - READ ENTIRE FILE NOW: Read CODE0 completely from start to finish. NEVER set any range limits when reading this file. Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with presentation creation.
  2. PREREQUISITE - Install html2pptx library:
  1. CRITICAL: Plan the presentation
  1. CRITICAL: Set CSS variables
  1. Create an HTML file for each slide with proper dimensions (e.g., 960px × 540px for 16:9)
  1. Create and run a JavaScript file using the CODE0 library to convert HTML slides to PowerPoint and save the presentation

```javascript

import pptxgen from "pptxgenjs";

import { html2pptx } from "@ant/html2pptx";

// Create a new pptx presentation

const pptx = new pptxgen();

pptx.layout = "LAYOUT_16x9"; // Must match HTML body dimensions

// Add an HTML-only slide

await html2pptx("slide1.html", pptx);

// Add a HTML slide with chart placeholders

const { slide: slide2, placeholders } = await html2pptx("slide2.html", pptx);

slide2.addChart(pptx.charts.LINE, chartData, placeholders[0]);

// Save the presentation

await pptx.writeFile("output.pptx");

```

  1. Visual validation: Generate thumbnails and inspect for layout issues

Editing an existing PowerPoint presentation

To edit slides in an existing PowerPoint presentation, work with the raw Office Open XML (OOXML) format. This involves unpacking the .pptx file, editing the XML content, and repacking it.

Workflow

  1. MANDATORY - READ ENTIRE FILE: Read CODE0 (~500 lines) completely from start to finish. NEVER set any range limits when reading this file. Read the full file content for detailed guidance on OOXML structure and editing workflows before any presentation editing.
  2. Unpack the presentation: python /mnt/skills/public/pptx/ooxml/scripts/unpack.py <office_file> <output_dir>
  3. Edit the XML files (primarily ppt/slides/slide{N}.xml and related files)
  4. CRITICAL: Validate immediately after each edit and fix any validation errors before proceeding: python /mnt/skills/public/pptx/ooxml/scripts/validate.py <dir> --original <file>
  5. Pack the final presentation: python /mnt/skills/public/pptx/ooxml/scripts/pack.py <input_directory> <office_file>

Creating a new PowerPoint presentation **using a template**

To create a presentation that follows an existing template's design, duplicate and re-arrange template slides before replacing placeholder content.

Workflow

  1. Extract template text AND create visual thumbnail grid:
  1. Analyze template and save inventory to a file:

```markdown

# Template Inventory Analysis

Total Slides: [count]

IMPORTANT: Slides are 0-indexed (first slide = 0, last slide = count-1)

## [Category Name]

[... EVERY slide must be listed individually with its index ...]

```

  1. Create presentation outline based on template inventory:

```

# Template slides to use (0-based indexing)

# WARNING: Verify indices are within range! Template with 73 slides has indices 0-72

# Mapping: slide numbers from outline -> template slide indices

template_mapping = [

0, # Use slide 0 (Title/Cover)

34, # Use slide 34 (B1: Title and body)

34, # Use slide 34 again (duplicate for second B1)

50, # Use slide 50 (E1: Quote)

54, # Use slide 54 (F2: Closing + Text)

]

```

  1. Duplicate, reorder, and delete slides using rearrange.py:

```bash

python /mnt/skills/public/pptx/scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52

```

  1. Extract ALL text using the inventory.py script:

```bash

python /mnt/skills/public/pptx/scripts/inventory.py working.pptx text-inventory.json

```

```json

{

"slide-0": {

"shape-0": {

"placeholder_type": "TITLE", // or null for non-placeholders

"left": 1.5, // position in inches

"top": 2.0,

"width": 7.5,

"height": 1.2,

"paragraphs": [

{

"text": "Paragraph text",

// Optional properties (only included when non-default):

"bullet": true, // explicit bullet detected

"level": 0, // only included when bullet is true

"alignment": "CENTER", // CENTER, RIGHT (not LEFT)

"space_before": 10.0, // space before paragraph in points

"space_after": 6.0, // space after paragraph in points

"line_spacing": 22.4, // line spacing in points

"font_name": "Arial", // from first run

"font_size": 14.0, // in points

"bold": true,

"italic": false,

"underline": false,

"color": "FF0000" // RGB color

}

]

}

}

}

```

  1. Generate replacement text and save the data to a JSON file

Based on the text inventory from the previous step:

Example paragraphs field showing proper formatting:

```json

"paragraphs": [

{

"text": "New presentation title text",

"alignment": "CENTER",

"bold": true

},

{

"text": "Section Header",

"bold": true

},

{

"text": "First bullet point without bullet symbol",

"bullet": true,

"level": 0

},

{

"text": "Red colored text",

"color": "FF0000"

},

{

"text": "Theme colored text",

"theme_color": "DARK_1"

},

{

"text": "Regular paragraph text without special formatting"

}

]

```

Shapes not listed in the replacement JSON are automatically cleared:

```json

{

"slide-0": {

"shape-0": {

"paragraphs": [...] // This shape gets new text

}

// shape-1 and shape-2 from inventory will be cleared automatically

}

}

```

Common formatting patterns for presentations:

  1. Apply replacements using the replace.py script

```bash

python /mnt/skills/public/pptx/scripts/replace.py working.pptx replacement-text.json output.pptx

```

The script will:

Example validation errors:

```

ERROR: Invalid shapes in replacement JSON:

```

```

ERROR: Replacement text made overflow worse in these shapes:

```

Creating Thumbnail Grids

To create visual thumbnail grids of PowerPoint slides for quick analysis and reference:

python /mnt/skills/public/pptx/scripts/thumbnail.py template.pptx [output_prefix]

Features:

Use cases:

Examples:

# Basic usage
python /mnt/skills/public/pptx/scripts/thumbnail.py presentation.pptx

# Combine options: custom name, columns
python /mnt/skills/public/pptx/scripts/thumbnail.py template.pptx analysis --cols 4

Converting Slides to Images

To visually analyze PowerPoint slides, convert them to images using a two-step process:

  1. Convert PPTX to PDF:

```bash

soffice --headless --convert-to pdf template.pptx

```

  1. Convert PDF pages to JPEG images:

```bash

pdftoppm -jpeg -r 150 template.pdf slide

```

This creates files like slide-1.jpg, slide-2.jpg, etc.

Options:

Example for specific range:

pdftoppm -jpeg -r 150 -f 2 -l 5 template.pdf slide  # Converts only pages 2-5

Design Guidelines (MANDATORY)

Every presentation must have intentional visual design. Never create unstyled slides.

  1. Analyze the topic first: What colors, mood, and tone fit the subject?
  2. Choose a color palette: Select 2-3 colors that match the content. Reference css.md for available CSS variables.
  3. Use consistent typography: Headings in bold/larger size, body in regular weight. Stick to web-safe fonts.
  4. Apply visual hierarchy: Use size, weight, color, and spacing to guide the reader's eye.
  5. Keep slides concise: 3-5 bullet points max, 1-2 sentence paragraphs. This is a presentation, not a report.

Example CSS override for a tech presentation:

:root {
  --color-primary: #2563eb;
  --color-surface: #0f172a;
  --color-surface-foreground: #f8fafc;
  --font-family-display: 'Trebuchet MS', sans-serif;
}

For brand-specific presentations, ask the user for brand colors/fonts and apply them as CSS variable overrides.

Code Style Guidelines

IMPORTANT: When generating code for PPTX operations:

Dependencies

Required dependencies (should already be installed):

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.