pptx
Work with PowerPoint .pptx files using python-pptx (preinstalled). A .pptx
is a ZIP of XML parts; python-pptx handles the structure so you rarely touch XML.
Drop to raw OOXML only for the few things the library can't express (see Advanced).
All work happens in the sandbox exec shell, in the current workspace dir where
uploaded files land. Write a short Python heredoc or temp .py and run it.
After exec completes, use the Generated artifacts URL from the tool result in
the final answer so the user can download the deck.
Mental model
- A presentation has slides; each slide is built from a layout; layouts
live on slide masters. Layouts define placeholders (title, body,
picture, etc.) by
idxand type. - A slide holds shapes: placeholders, text boxes, pictures, tables, charts.
- Shapes with text expose
.text_frame→.paragraphs→.runs. A run is the unit that carries formatting (font, size, bold, color). - Units are EMU. Use the helpers:
from pptx.util import Inches, Pt, Emu.
Read / extract
from pptx import Presentation
prs = Presentation("deck.pptx")
print(len(prs.slides), prs.slide_width, prs.slide_height) #…