Presentations
Purpose
Build slide decks programmatically, using the template's layouts rather than positioning text boxes by hand — and with a structure that carries an argument rather than a list of topics.
When to Use
- Generating a deck from data or a document.
- Editing an existing
.pptx.
- Extracting content or speaker notes from a deck.
- Applying a corporate template to generated content.
Capabilities
- Slide generation using template layouts and placeholders.
- Charts, tables, and images with correct positioning.
- Speaker notes.
- Content extraction from existing decks.
- Template application and brand compliance.
Inputs
- The content and the argument it should make.
- The template, if there is a house style.
- The audience and the setting — read in a room, or sent as a document.
Outputs
- A
.pptx using the template's layouts, not free-floating text boxes.
- One idea per slide.
- Speaker notes carrying the detail that does not belong on the slide.
Workflow
- Write the argument before the slides — What is the conclusion, and what supports it? A deck assembled from available material rather than toward a point is a document with page breaks.
- Use the template's layouts — Each layout has placeholders. Filling a placeholder inherits the template's fonts, sizes, and positions. Adding a free-floating text box does not, and it will look wrong on a projector.
- One idea per slide — The slide title should state the point, not the topic. "Revenue grew 40% on enterprise expansion" is a title; "Revenue" is a label.
- Put the detail in the notes — The slide carries the point; the speaker or the notes carry the argument. A slide with eight bullet points will be read instead of listened to.
- Verify it renders — Open it. Text that overflows its placeholder is invisible in the XML and obvious on screen.
Best Practices
- Use placeholders, not text boxes. A deck built from free-positioned text boxes ignores the template entirely, and it will be visibly off-brand.
- The title of a slide should be a claim. If every title is a noun, the deck has no argument.
- Text overflowing a placeholder does not error — it is silently clipped or shrunk. Check the rendered output, always.
- Images must maintain their aspect ratio. Setting both width and height distorts them, and it looks amateurish.
- A chart built in PowerPoint is editable and rescales; a chart pasted as an image does not. Prefer native charts for anything that may need revision.
- Speaker notes are where the detail goes. They are also what makes the deck useful to someone who was not in the room.
Examples
Building on a template's layouts:
from pptx import Presentation
from pptx.util import Inches, Pt
prs = Presentation("templates/corporate.pptx") # inherit the house style
# Layouts come from the template. Inspect them rather than guessing indices.
# for i, layout in enumerate(prs.slide_layouts):
# print(i, layout.name)
# 0 Title Slide | 1 Title and Content | 5 Title Only | 6 Blank
title_slide = prs.slides.add_slide(prs.slide_layouts[0])
title_slide.shapes.title.text = "Q2 Operations Review"
title_slide.placeholders[1].text = "Platform Team | July 2026"
# A slide whose title is a claim, not a label.
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "Availability met target every month; two incidents exceeded RTO"
body = slide.placeholders[1].text_frame
body.text = "99.94% availability against a 99.9% target"
for point in [
"Two incidents exceeded the 30-minute recovery objective",
"Both traced to the same cause: no automated rollback on the pricing service",
"Automated rollback ships this quarter",
]:
p = body.add_paragraph()
p.text = point
p.level = 1
# The detail lives in the notes, not on the slide.
slide.notes_slide.notes_text_frame.text = (
"The 99.94% figure is the weighted average across all three regions. "
"eu-west-1 was 99.87% in May, below target, driven entirely by the "
"14 May incident. Without automated rollback, mean recovery time is "
"41 minutes against a 30-minute objective — the incidents were not "
"unusually severe, the recovery was unusually manual."
)
prs.save("output/q2-review.pptx")
A native chart rather than a pasted image:
from pptx.chart.data import CategoryChartData
from pptx.enum.chart import XL_CHART_TYPE
slide = prs.slides.add_slide(prs.slide_layouts[5])
slide.shapes.title.text = "Incident count fell 40% after the rollback change"
chart_data = CategoryChartData()
chart_data.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
chart_data.add_series("Incidents", (12, 14, 11, 8, 7, 7))
slide.shapes.add_chart(
XL_CHART_TYPE.COLUMN_CLUSTERED,
Inches(1), Inches(1.8), Inches(8), Inches(4.5),
chart_data,
)
# Editable in PowerPoint, rescales with the slide, and readable on a projector.
Notes
- The layout indices in a template are not standardized. Print the layout names before using them, or you will place a title into a picture placeholder.
- Text that overflows a placeholder is the most common defect in a generated deck, and it is invisible until the file is opened. Budget the text length, or enable autofit.
- If the deck will be sent rather than presented, the slides must carry more of the argument — but the answer is usually a document, not a denser deck.
1---2name: presentations3description: Use when creating or editing slide decks (.pptx). Covers slide structure, using layouts and templates correctly, charts and images, speaker notes, and building a deck that communicates rather than decorates.4---56# Presentations78## Purpose910Build slide decks programmatically, using the template's layouts rather than positioning text boxes by hand — and with a structure that carries an argument rather than a list of topics.1112## When to Use1314- Generating a deck from data or a document.15- Editing an existing `.pptx`.16- Extracting content or speaker notes from a deck.17- Applying a corporate template to generated content.1819## Capabilities2021- Slide generation using template layouts and placeholders.22- Charts, tables, and images with correct positioning.23- Speaker notes.24- Content extraction from existing decks.25- Template application and brand compliance.2627## Inputs2829- The content and the argument it should make.30- The template, if there is a house style.31- The audience and the setting — read in a room, or sent as a document.3233## Outputs3435- A `.pptx` using the template's layouts, not free-floating text boxes.36- One idea per slide.37- Speaker notes carrying the detail that does not belong on the slide.3839## Workflow40411. **Write the argument before the slides** — What is the conclusion, and what supports it? A deck assembled from available material rather than toward a point is a document with page breaks.422. **Use the template's layouts** — Each layout has placeholders. Filling a placeholder inherits the template's fonts, sizes, and positions. Adding a free-floating text box does not, and it will look wrong on a projector.433. **One idea per slide** — The slide title should state the point, not the topic. "Revenue grew 40% on enterprise expansion" is a title; "Revenue" is a label.444. **Put the detail in the notes** — The slide carries the point; the speaker or the notes carry the argument. A slide with eight bullet points will be read instead of listened to.455. **Verify it renders** — Open it. Text that overflows its placeholder is invisible in the XML and obvious on screen.4647## Best Practices4849- Use placeholders, not text boxes. A deck built from free-positioned text boxes ignores the template entirely, and it will be visibly off-brand.50- The title of a slide should be a claim. If every title is a noun, the deck has no argument.51- Text overflowing a placeholder does not error — it is silently clipped or shrunk. Check the rendered output, always.52- Images must maintain their aspect ratio. Setting both width and height distorts them, and it looks amateurish.53- A chart built in PowerPoint is editable and rescales; a chart pasted as an image does not. Prefer native charts for anything that may need revision.54- Speaker notes are where the detail goes. They are also what makes the deck useful to someone who was not in the room.5556## Examples5758**Building on a template's layouts:**5960```python61from pptx import Presentation62from pptx.util import Inches, Pt6364prs = Presentation("templates/corporate.pptx") # inherit the house style6566# Layouts come from the template. Inspect them rather than guessing indices.67# for i, layout in enumerate(prs.slide_layouts):68# print(i, layout.name)69# 0 Title Slide | 1 Title and Content | 5 Title Only | 6 Blank7071title_slide = prs.slides.add_slide(prs.slide_layouts[0])72title_slide.shapes.title.text = "Q2 Operations Review"73title_slide.placeholders[1].text = "Platform Team | July 2026"7475# A slide whose title is a claim, not a label.76slide = prs.slides.add_slide(prs.slide_layouts[1])77slide.shapes.title.text = "Availability met target every month; two incidents exceeded RTO"7879body = slide.placeholders[1].text_frame80body.text = "99.94% availability against a 99.9% target"8182for point in [83 "Two incidents exceeded the 30-minute recovery objective",84 "Both traced to the same cause: no automated rollback on the pricing service",85 "Automated rollback ships this quarter",86]:87 p = body.add_paragraph()88 p.text = point89 p.level = 19091# The detail lives in the notes, not on the slide.92slide.notes_slide.notes_text_frame.text = (93 "The 99.94% figure is the weighted average across all three regions. "94 "eu-west-1 was 99.87% in May, below target, driven entirely by the "95 "14 May incident. Without automated rollback, mean recovery time is "96 "41 minutes against a 30-minute objective — the incidents were not "97 "unusually severe, the recovery was unusually manual."98)99100prs.save("output/q2-review.pptx")101```102103**A native chart rather than a pasted image:**104105```python106from pptx.chart.data import CategoryChartData107from pptx.enum.chart import XL_CHART_TYPE108109slide = prs.slides.add_slide(prs.slide_layouts[5])110slide.shapes.title.text = "Incident count fell 40% after the rollback change"111112chart_data = CategoryChartData()113chart_data.categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]114chart_data.add_series("Incidents", (12, 14, 11, 8, 7, 7))115116slide.shapes.add_chart(117 XL_CHART_TYPE.COLUMN_CLUSTERED,118 Inches(1), Inches(1.8), Inches(8), Inches(4.5),119 chart_data,120)121# Editable in PowerPoint, rescales with the slide, and readable on a projector.122```123124## Notes125126- The layout indices in a template are not standardized. Print the layout names before using them, or you will place a title into a picture placeholder.127- Text that overflows a placeholder is the most common defect in a generated deck, and it is invisible until the file is opened. Budget the text length, or enable autofit.128- If the deck will be sent rather than presented, the slides must carry more of the argument — but the answer is usually a document, not a denser deck.