Pptx Engine
All-in-one skill covering presentation, creation, editing, analysis. Includes structured workflows, validation checks, and reusable patterns for document processing.
PPTX Engine
A comprehensive skill for creating, editing, and analyzing PowerPoint presentations programmatically. Covers slide creation with layouts, text formatting, images, charts, tables, and animations using Python and Node.js libraries.
When to Use This Skill
Choose this skill when:
- Creating PowerPoint presentations from data or templates
- Generating automated reports as PPTX slide decks
- Extracting content and structure from existing presentations
- Batch-modifying slides across multiple presentations
- Converting between PPTX and other formats
Consider alternatives when:
- Working with DOCX documents → use a DOCX skill
- Creating PDF reports → use a PDF creation skill
- Building web-based slide decks → use reveal.js or similar
- Creating simple image-based slides → use an image generation tool
Quick Start
from pptx import Presentation from pptx.util import Inches, Pt, Emu from pptx.enum.text import PP_ALIGN from pptx.dml.color import RGBColor prs = Presentation() # Title slide slide = prs.slides.add_slide(prs.slide_layouts[0]) slide.shapes.title.text = "Q1 2024 Report" slide.placeholders[1].text = "Engineering Team Update" # Content slide with bullet points slide = prs.slides.add_slide(prs.slide_layouts[1]) slide.shapes.title.text = "Key Achievements" body = slide.placeholders[1] tf = body.text_frame tf.text = "Shipped v2.0 with 15 new features" p = tf.add_paragraph() p.text = "Reduced p99 latency by 40%" p.level = 0 p = tf.add_paragraph() p.text = "Onboarded 5 new team members" p.level = 0 # Slide with table slide = prs.slides.add_slide(prs.slide_layouts[5]) slide.shapes.title.text = "Performance Metrics" table = slide.shapes.add_table(4, 3, Inches(1), Inches(2), Inches(8), Inches(3)).table table.cell(0, 0).text = "Metric" table.cell(0, 1).text = "Target" table.cell(0, 2).text = "Actual" data = [("Uptime", "99.9%", "99.95%"), ("Latency", "<200ms", "145ms"), ("Errors", "<0.1%", "0.05%")] for row_idx, (metric, target, actual) in enumerate(data, 1): table.cell(row_idx, 0).text = metric table.cell(row_idx, 1).text = target table.cell(row_idx, 2).text = actual prs.save('q1_report.pptx')
Core Concepts
PPTX Structure
| Component | Description | python-pptx Class |
|---|---|---|
| Presentation | The file itself | Presentation() |
| Slide Layout | Template for slide structure | slide_layouts[n] |
| Slide | Individual slide | slides.add_slide() |
| Shape | Any element on a slide | shapes collection |
| Text Frame | Container for text | shape.text_frame |
| Paragraph | Text paragraph | text_frame.paragraphs |
| Run | Formatted text segment | paragraph.runs |
| Table | Grid of cells | shapes.add_table() |
| Chart | Data visualization | shapes.add_chart() |
| Picture | Embedded image | shapes.add_picture() |
Chart Creation
from pptx.chart.data import CategoryChartData from pptx.enum.chart import XL_CHART_TYPE slide = prs.slides.add_slide(prs.slide_layouts[5]) chart_data = CategoryChartData() chart_data.categories = ['Q1', 'Q2', 'Q3', 'Q4'] chart_data.add_series('Revenue', (1.2, 1.5, 1.8, 2.1)) chart_data.add_series('Costs', (0.8, 0.9, 1.0, 1.1)) chart = slide.shapes.add_chart( XL_CHART_TYPE.COLUMN_CLUSTERED, Inches(1), Inches(1.5), Inches(8), Inches(5), chart_data ).chart chart.has_legend = True chart.legend.include_in_layout = False chart.style = 10 # Built-in style
Content Extraction
def extract_pptx_content(path: str) -> list[dict]: prs = Presentation(path) slides_data = [] for i, slide in enumerate(prs.slides): slide_data = { 'number': i + 1, 'layout': slide.slide_layout.name, 'texts': [], 'tables': [], 'images': [], } for shape in slide.shapes: if shape.has_text_frame: text = shape.text_frame.text if text.strip(): slide_data['texts'].append(text) if shape.has_table: table = shape.table rows = [] for row in table.rows: rows.append([cell.text for cell in row.cells]) slide_data['tables'].append(rows) if shape.shape_type == 13: # Picture slide_data['images'].append(shape.image.blob) slides_data.append(slide_data) return slides_data
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
slideWidth | number | 10 | Slide width in inches (default: widescreen) |
slideHeight | number | 7.5 | Slide height in inches |
defaultFont | string | 'Calibri' | Default font for text |
defaultFontSize | number | 18 | Default font size in points |
templatePath | string | '' | Path to template PPTX for styling |
chartStyle | number | 10 | Default chart style number |
Best Practices
-
Use a template presentation for consistent branding — Load an existing PPTX with corporate styling as the base:
Presentation('template.pptx'). This inherits slide layouts, color schemes, and fonts automatically. -
Work with slide layouts, not blank slides — Slide layouts define placeholder positions for titles, content, and images. Using layouts produces professional-looking slides without manual positioning of every element.
-
Set text formatting at the run level, not paragraph level — Different words in the same paragraph may need different formatting. Use runs for granular control:
run.font.bold = True,run.font.size = Pt(24). -
Convert to PDF for distribution, keep PPTX for editing — Generate the PPTX for editing capability, then convert to PDF (
libreoffice --convert-to pdf) for distribution. This prevents formatting differences across PowerPoint versions. -
Test generated presentations in PowerPoint and LibreOffice — python-pptx produces valid OOXML, but rendering can differ between applications. Test with both to catch compatibility issues.
Common Issues
Slide layout doesn't match expected placeholder positions — Different PPTX templates define different layouts. List available layouts and their placeholders before using them: for layout in prs.slide_layouts: print(layout.name).
Charts don't display data correctly — Category and series data must align in dimensions. Verify that categories count matches the data points in each series. Check chart type compatibility with your data structure.
Images stretch or distort — Always specify both width and height, or calculate proportional dimensions from the original aspect ratio. Use shape.width and shape.height to control exact placement.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.