pptx

PPTX Processing Skill

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "pptx" with this command: npx skills add vamseeachanta/workspace-hub/vamseeachanta-workspace-hub-pptx

PPTX Processing Skill

Overview

This skill provides three primary workflows for PowerPoint manipulation: creating from scratch, editing existing presentations, and using templates.

Quick Start

from pptx import Presentation from pptx.util import Inches, Pt

prs = Presentation()

Add title slide

title_slide = prs.slides.add_slide(prs.slide_layouts[0]) title_slide.shapes.title.text = "My Presentation" title_slide.placeholders[1].text = "By Claude"

prs.save("presentation.pptx")

When to Use

  • Creating automated presentation reports

  • Building slide decks from data

  • Generating pitch presentations

  • Converting HTML content to slides

  • Adding charts and tables to presentations

  • Batch processing multiple presentations

  • Updating existing presentations programmatically

  • Creating consistent branded presentations from templates

Creating New Presentations

Basic Creation with python-pptx

from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.text import PP_ALIGN

prs = Presentation()

Add title slide

title_slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(title_slide_layout) title = slide.shapes.title subtitle = slide.placeholders[1]

title.text = "Presentation Title" subtitle.text = "Subtitle or Author"

Add content slide

bullet_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(bullet_slide_layout) shapes = slide.shapes

title_shape = shapes.title body_shape = shapes.placeholders[1]

title_shape.text = "Slide Title" tf = body_shape.text_frame tf.text = "First bullet point"

p = tf.add_paragraph() p.text = "Second bullet point" p.level = 0

p = tf.add_paragraph() p.text = "Sub-bullet" p.level = 1

prs.save("presentation.pptx")

Add Images

from pptx import Presentation from pptx.util import Inches

prs = Presentation() blank_slide_layout = prs.slide_layouts[6] slide = prs.slides.add_slide(blank_slide_layout)

left = Inches(1) top = Inches(1) width = Inches(5)

slide.shapes.add_picture("image.png", left, top, width=width)

prs.save("with_image.pptx")

Add Charts

from pptx import Presentation from pptx.chart.data import CategoryChartData from pptx.enum.chart import XL_CHART_TYPE from pptx.util import Inches

prs = Presentation() slide = prs.slides.add_slide(prs.slide_layouts[6])

chart_data = CategoryChartData() chart_data.categories = ['Q1', 'Q2', 'Q3', 'Q4'] chart_data.add_series('Sales', (19.2, 21.4, 16.7, 28.0)) chart_data.add_series('Expenses', (14.2, 18.3, 15.4, 20.1))

x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5) slide.shapes.add_chart( XL_CHART_TYPE.COLUMN_CLUSTERED, x, y, cx, cy, chart_data )

prs.save("with_chart.pptx")

Add Tables

from pptx import Presentation from pptx.util import Inches

prs = Presentation() slide = prs.slides.add_slide(prs.slide_layouts[6])

rows, cols = 3, 4 left = Inches(1) top = Inches(2) width = Inches(6) height = Inches(2)

table = slide.shapes.add_table(rows, cols, left, top, width, height).table

Set column widths

for col_idx in range(cols): table.columns[col_idx].width = Inches(1.5)

Fill cells

for row_idx, row in enumerate(table.rows): for col_idx, cell in enumerate(row.cells): cell.text = f"R{row_idx+1}C{col_idx+1}"

prs.save("with_table.pptx")

Design Principles

Before Writing Code

State your content-informed design approach:

  • What is the purpose and tone?

  • Select colors that genuinely match the topic

  • Plan visual hierarchy and layout

  • Consider typography choices

Professional Styling

from pptx import Presentation from pptx.util import Inches, Pt from pptx.dml.color import RGBColor from pptx.enum.text import PP_ALIGN

prs = Presentation() slide = prs.slides.add_slide(prs.slide_layouts[6])

Add styled text box

left = Inches(1) top = Inches(1) width = Inches(8) height = Inches(1)

txBox = slide.shapes.add_textbox(left, top, width, height) tf = txBox.text_frame

p = tf.paragraphs[0] p.text = "Styled Heading" p.font.size = Pt(44) p.font.bold = True p.font.color.rgb = RGBColor(0x2E, 0x74, 0xB5) p.alignment = PP_ALIGN.CENTER

prs.save("styled.pptx")

Editing Existing Presentations

Read and Modify

from pptx import Presentation

prs = Presentation("existing.pptx")

for slide in prs.slides: for shape in slide.shapes: if shape.has_text_frame: for paragraph in shape.text_frame.paragraphs: for run in paragraph.runs: if "old text" in run.text: run.text = run.text.replace("old text", "new text")

prs.save("modified.pptx")

Extract Text

from pptx import Presentation

prs = Presentation("presentation.pptx")

for slide_num, slide in enumerate(prs.slides, 1): print(f"\n--- Slide {slide_num} ---") for shape in slide.shapes: if shape.has_text_frame: for paragraph in shape.text_frame.paragraphs: print(paragraph.text)

Copy Slides

from pptx import Presentation from copy import deepcopy

prs = Presentation("source.pptx")

Note: python-pptx doesn't directly support slide copying

Use slide layouts from the same presentation instead

Using Templates

Apply Template

from pptx import Presentation

Open template

prs = Presentation("template.pptx")

Add slides using template layouts

slide_layout = prs.slide_layouts[1] # Use template's layout slide = prs.slides.add_slide(slide_layout)

Fill placeholders

for shape in slide.placeholders: print(f"{shape.placeholder_format.idx}: {shape.name}")

prs.save("from_template.pptx")

OOXML Editing (Advanced)

For complex modifications, work directly with XML:

Unpack Presentation

unzip presentation.pptx -d presentation_extracted/

Edit XML

Navigate to ppt/slides/ and edit slide1.xml , etc.

Repack

cd presentation_extracted zip -r ../modified.pptx .

Execution Checklist

  • Define presentation purpose and audience

  • Plan slide structure before coding

  • Use consistent styling throughout

  • Verify all images exist and are accessible

  • Test output in PowerPoint/LibreOffice

  • Check chart data accuracy

  • Validate table formatting

Error Handling

Common Errors

Error: KeyError on placeholder

  • Cause: Placeholder index doesn't exist in layout

  • Solution: List placeholders first with slide.placeholders

Error: Image not found

  • Cause: Image path is incorrect

  • Solution: Use absolute paths or verify relative path

Error: Font not available

  • Cause: System font missing

  • Solution: Use common fonts or embed fonts

Error: PackageNotFoundError

  • Cause: Template file not found or corrupt

  • Solution: Verify template path and file integrity

Metrics

Metric Typical Value

Slide creation ~50 slides/second

Chart generation ~10 charts/second

Table creation ~20 tables/second

Image insertion ~30 images/second

Memory usage ~20MB per presentation

Quick Reference

Task Method

Create presentation Presentation()

Add slide slides.add_slide(layout)

Add text add_textbox()

Add image add_picture()

Add chart add_chart()

Add table add_table()

Style text font.size, font.bold, font.color

Dependencies

pip install python-pptx

Optional tools:

  • LibreOffice (for PDF conversion)

  • Pandoc (for format conversion)

Version History

  • 1.1.0 (2026-01-02): Added Quick Start, When to Use, Execution Checklist, Error Handling, Metrics sections; updated frontmatter with version, category, related_skills

  • 1.0.0 (2024-10-15): Initial release with python-pptx, templates, OOXML editing

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

echarts

No summary provided by upstream source.

Repository SourceNeeds Review
General

pandoc

No summary provided by upstream source.

Repository SourceNeeds Review
General

mkdocs

No summary provided by upstream source.

Repository SourceNeeds Review
General

gis

No summary provided by upstream source.

Repository SourceNeeds Review