{"id":101475,"plugin_id":"plugins_6af4333b6f008191806d76e5f43ec5f9","kind":"skill","collection_source":"plugin_package","comparison_source":null,"observed_at":"2026-11-17T12:11:35.719Z","digest":"32a92dede61b4c5e4ae68d600fe6fd36b15dd14e18ac44be592c8a435c86a108","against":null,"payload":{"description":"Create, edit, and read PowerPoint presentations (.pptx) with python-pptx. Use whenever the user wants slides as output — a deck, pitch, briefing, training, or report presentation — or uploads a .pptx to summarize, restyle, update, or extend, even if they only say “slides” or “deck”.","included_files":[],"name":"pptx","skill_md_contents":"---\nname: pptx\ndescription: Create, edit, and read PowerPoint presentations (.pptx) with python-pptx. Use whenever the user wants slides as output — a deck, pitch, briefing, training, or report presentation — or uploads a .pptx to summarize, restyle, update, or extend, even if they only say “slides” or “deck”.\nlicense: Apache-2.0\ncompatibility: Tines 3B\n---\n\n# PowerPoint presentations\n\nWork with `.pptx` files in Python through `execute`, adding `python-pptx==1.0.2` to a `requirements.txt` in `files`. In a workflow step, add it to the step’s `requirements.txt` instead.\n\nUser uploads arrive under `/3b/uploads/<id>/<file>`, which every execution can read. Write output to a persistent volume, such as `volumes: [\"documents\"]` and `/storage/documents/briefing.pptx`, then call `showStorageFile` so the user can preview and download it. Never overwrite the user’s upload: save edits as a new file, and call `showStorageFile` again after each change.\n\n## Reading\n\n```python\nfrom pptx import Presentation\n\nprs = Presentation(\"/3b/uploads/abc/deck.pptx\")\nfor number, slide in enumerate(prs.slides, start=1):\n    print(f\"--- Slide {number} ({slide.slide_layout.name})\")\n    for shape in slide.shapes:\n        if shape.has_text_frame and shape.text_frame.text.strip():\n            print(shape.text_frame.text)\n        if shape.has_table:\n            for row in shape.table.rows:\n                print(\" | \".join(cell.text for cell in row.cells))\n    if slide.has_notes_slide:\n        print(\"Notes:\", slide.notes_slide.notes_text_frame.text)\n```\n\nGroup shapes hold their own `shapes`, so recurse into them when text seems missing.\n\n## Plan the deck before writing code\n\nDraft the outline as text first: one line per slide with its title and the point it makes. Confirm it with the user when the request is open-ended. The outline is cheap to change, and the code is not.\n\n- **One idea per slide, with the title stating it.** “Phishing reports doubled after the training” beats “Phishing reports”.\n- **Keep text short.** At most five or six bullets, each a single line. Move detail into speaker notes.\n- **Show numbers as charts or big figures**, not as sentences full of digits.\n- **Be consistent.** Use one title position, one margin, two fonts at most, and a palette of a neutral, a dark text color, and one or two accents.\n\n## Creating\n\nWhen the user supplies a template or an existing deck in their branding, open it and add slides from its layouts. Its masters carry fonts, colors, and logos you shouldn’t recreate by hand. Otherwise, start from the default and switch it to 16:9, because python-pptx’s default is 4:3.\n\n```python\nfrom pptx import Presentation\nfrom pptx.chart.data import CategoryChartData\nfrom pptx.dml.color import RGBColor\nfrom pptx.enum.chart import XL_CHART_TYPE, XL_LEGEND_POSITION\nfrom pptx.util import Inches, Pt\n\nprs = Presentation()\nprs.slide_width, prs.slide_height = Inches(13.333), Inches(7.5)\nTITLE_ONLY = prs.slide_layouts[5]\nACCENT = RGBColor(0x1F, 0x4E, 0x79)\n\nslide = prs.slides.add_slide(prs.slide_layouts[0])\nslide.shapes.title.text = \"Security operations, Q3\"\nslide.placeholders[1].text = \"Board briefing\"\n\nslide = prs.slides.add_slide(TITLE_ONLY)\nslide.shapes.title.text = \"Phishing reports doubled after the training\"\ndata = CategoryChartData()\ndata.categories = [\"Jul\", \"Aug\", \"Sep\"]\ndata.add_series(\"Reports\", (120, 180, 260))\nchart = slide.shapes.add_chart(\n    XL_CHART_TYPE.COLUMN_CLUSTERED, Inches(0.75), Inches(1.6), Inches(11.8), Inches(5.4), data\n).chart\nchart.has_legend = False\nchart.plots[0].series[0].format.fill.solid()\nchart.plots[0].series[0].format.fill.fore_color.rgb = ACCENT\nslide.notes_slide.notes_text_frame.text = \"Training launched July 14.\"\n\nslide = prs.slides.add_slide(TITLE_ONLY)\nslide.shapes.title.text = \"Next steps\"\nbody = slide.shapes.add_textbox(Inches(0.75), Inches(1.6), Inches(11.8), Inches(5)).text_frame\nbody.word_wrap = True\nfor index, line in enumerate([\"Roll out to contractors\", \"Automate triage of reports\"]):\n    paragraph = body.paragraphs[0] if index == 0 else body.add_paragraph()\n    paragraph.text = line\n    paragraph.font.size = Pt(24)\n\nprs.save(\"/storage/documents/briefing.pptx\")\n```\n\n- The default template’s layouts are 0 title, 1 title and content, 5 title only, and 6 blank. A user template has its own, so list `layout.name` for each layout and each placeholder’s `placeholder_format.idx` before you pick one.\n- After widening the default template to 16:9, its placeholders keep their 4:3 positions. Use title-only or blank layouts and place your own text boxes, or reposition each placeholder.\n- Use native charts (`add_chart`) and tables (`add_table`) so the user can edit them in PowerPoint. Reserve matplotlib images for chart types PowerPoint lacks.\n- Add images with `slide.shapes.add_picture(path, left, top, width=...)`. Set only width or only height so the aspect ratio holds.\n- Use 36–44 pt for titles, 20–28 pt for body text, and nothing below 14 pt.\n\n## Text doesn’t shrink to fit\n\npython-pptx writes text without measuring it, and auto-fit happens only when PowerPoint edits the shape, so long text silently overflows its box. Size boxes generously and keep text within these rough limits for a 16:9 slide: a title of about 60 characters on one line, and about 45 characters per line of 24 pt body text in a full-width box. Split a slide in two before shrinking the font.\n\n## Editing an existing deck\n\n- Replace text run by run, keeping each run’s formatting, rather than setting `text_frame.text`, which resets it.\n- python-pptx has no public API to delete, duplicate, or reorder slides. Reorder by moving entries in `prs.slides._sldIdLst`. Delete by removing the entry and dropping the relationship: `prs.part.drop_rel(entry.rId)`.\n- Fill a slide from the template’s layouts instead of copying shapes between decks, because shapes copied between files lose their images and charts.\n\n## Check the result\n\nReopen the saved file and print each slide’s title, its shape count, and any shape that extends past the slide edge (`shape.left + shape.width > prs.slide_width`, and the same for height). Then call `showStorageFile` so the user can page through the rendered deck, and summarize the slide list for them.\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}