Pptx

From guanyang/open-agent-hub · View interactive version

Pptx is an AI agent skill from the GitHub repository guanyang/open-agent-hub. Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em

How to use this skill

Skill file

PPTX creation, editing, and analysis

A .pptx is a ZIP archive of XML files. Choose your approach by task:

| Task | Approach |

|---|---|

| Create a new deck | Write a pptxgenjs script — see gotchas below — and build it as a structured deck unless the user asks for a quick throwaway |

| Edit an existing deck, or build from a template | unpack → edit ppt/slides/slideN.xml → zip |

| Read content | python scripts/slide_text.py deck.pptx (one block per slide under <!-- Slide number: N --> markers); visual grid: python scripts/thumbnail.py deck.pptx |

Scripts

Paths are relative to this skill's directory. Everything else is plain Python, node, or shell.

| Script | What it does |

|---|---|

| scripts/slide_text.py deck.pptx | Every slide's title, text, tables, chart data (scatter and bubble charts: series names only), picture alt text and speaker notes, as markdown. Reads .potx too |

| scripts/thumbnail.py deck.pptx [prefix] | Labeled grid of every slide, for picking template layouts. .pptx only. Pass prefix — it defaults to thumbnails, which overwrites the grids of any other deck done in the same directory |

| scripts/add_slide.py unpacked/ slide2.xml [--after slideN.xml] | Duplicate a slide (or a slideLayoutN.xml) with all the package bookkeeping. Also takes a .pptx directly with -o out.pptx |

| scripts/clean.py unpacked/ | Delete slides, media, and rels no longer referenced. Run after <p:sldIdLst> is final |

| scripts/apply_theme.js | Node module: const { applyTheme } = require("<this skill's directory>/scripts/apply_theme.js"). await applyTheme("deck.pptx", THEME) after pres.writeFile() writes THEME's colors and name (escaped for XML) into the deck's theme, for structured decks. Also a CLI: node scripts/apply_theme.js deck.pptx theme.json |

| scripts/office/validate.py deck.pptx [--original src.pptx] | Schema, relationship, content-type, chart and slide checks; each failure names its fix. Pass --original for any template-derived deck — it baselines the schema checks against the template, so the template's own XSD errors don't read as yours |

| scripts/office/soffice.py --headless --convert-to pdf deck.pptx | LibreOffice wrapper — bare soffice hangs in this sandbox |

Creating with pptxgenjs — gotchas

pptxgenjs is preinstalled — do not run npm install first; write the script and require('pptxgenjs') directly. Only if that require fails: npm install pptxgenjs. The model knows the API; these are the footguns:

Structured decks

A deck built on a theme, layouts, placeholders and sections can be restyled in one place and edited in PowerPoint without fighting it. Build every new deck this way unless the user asks for a quick throwaway.

  1. Theme first: const THEME = { name, headFontFace, bodyFontFace, colors: { dk1, lt1, dk2, lt2, accent1 … accent6, hlink, folHlink } }, colors in hex. pres.theme takes the two fonts and nothing else. Name no font after that — titles get the heading font, other text the body font — except on chart text, which is hard-coded Arial: give its *FontFace options "+mn-lt" (theme body font; "+mj-lt" is the heading font).
  2. const C = pres.SchemeColor for every color — C.text1/C.text2 are dk1/dk2, C.background1/C.background2 are lt1/lt2. These take hex only, read from THEME: valGridLine.color, catGridLine.color, shadow.color, and on a one-series bar chart invertedColors or more than one chartColors. A scheme color there is written as <a:srgbClr val="bg2"/> without complaint, and being hex, these will not follow a later change of theme.
  3. Sections: pres.addSection({ title }) just before that section's first slide, then sectionTitle on every addSlide. A slide without one — or, when sections are all declared up front, a table's auto-paged continuation slides — lands in a stray "Default-N" section.
  4. One layout per slide frame (defineSlideMaster()): title, section divider, title only, chart + commentary, table; dark and light variants if the design alternates. Text regions are named placeholders carrying position, size, weight and color — chart, image and table placeholders need a color too, or prompt text and arrays of runs come out hard-coded 000000. Footer text, logo and slideNumber go on the layout, never on a slide.
  5. Fill by name: addSlide({ masterName, sectionTitle }), then addText("…", { placeholder: "title" }) with no position, size or color — the placeholder's own options win, and anything it doesn't set (italic, align, fontFace) still applies; style one run with [{ text, options }]. A misspelt placeholder or masterName fails silently (a stray text box at 0,0; the blank layout). Only title, body and chart placeholders fill by name alone: addImage({ placeholder }) takes the placeholder's x and y but not its size (a 1" × 1" picture) — pass w/h too. addTable({ placeholder }) takes its x and y only — always pass w; when it auto-pages it ignores the placeholder and runs off the slide, so also pass x, y and autoPageSlideStartY (same as y, or continuation pages are laid out from the top margin), give the layout a margin whose bottom clears the footer, and fill the continuation slides' titles through slide.newAutoPagedSlides.
  6. A layout is the frame, not the "layout" Design Ideas means. Cards, icons, stat callouts and images are still composed slide by slide on top of it, in scheme colors, each with an objectName — every Design Idea applies, and most content slides sit on the title-only layout.
  7. Write, then apply the theme: await pres.writeFile({ fileName: "deck.pptx" }), then await applyTheme("deck.pptx", THEME). pptxgenjs cannot write theme colors: until this runs, scheme colors resolve to Office's stock palette. It throws, changing nothing, on a scheme color in a hex-only option — fix what it names and rebuild.

Editing existing decks and templates

Pick layouts first: python scripts/thumbnail.py template.pptx template-thumbs writes a labeled grid of every slide and prints the file(s) it created — template-thumbs.jpg, split into template-thumbs-N.jpg past 12 slides. Always pass that second argument, named after the deck. It defaults to thumbnails, so two decks thumbnailed in one directory silently overwrite each other's grids — the first deck's are simply gone (template analysis only — visual QA needs the full-resolution renders from Converting to Images; it only accepts .pptx, so copy a .potx to a .pptx name first). Use it with slide_text.py to map each content section onto a template slide, and vary the layouts — don't put every section on the same title-and-bullets slide.

python3 -c "import sys,zipfile; zipfile.ZipFile(sys.argv[1]).extractall('unpacked')" deck.pptx
python scripts/add_slide.py unpacked/ slide2.xml --after slide2.xml   # duplicate a slide (or slideLayoutN.xml); prints the new slide's path
# reorder / delete slides = edit <p:sldIdLst> in ppt/presentation.xml
python scripts/clean.py unpacked/                                     # after deletions: removes orphaned slides, media, rels
# edit slide content in ppt/slides/slideN.xml
(cd unpacked && rm -f ../out.pptx && zip -XrDy ../out.pptx .)         # zip from INSIDE the dir; rm first or deleted parts survive
python scripts/office/validate.py out.pptx --original deck.pptx

When filling in a template:

Deck content and flow

Design Ideas

Don't create boring slides. Plain bullets on a white background won't impress anyone. Consider ideas from this list for each slide.

Before Starting

Color Palettes

Choose colors that match your topic — don't default to generic blue. Use these palettes as inspiration:

| Theme | Primary | Secondary | Accent |

|-------|---------|-----------|--------|

| Midnight Executive | 1E2761 (navy) | CADCFC (ice blue) | FFFFFF (white) |

| Forest & Moss | 2C5F2D (forest) | 97BC62 (moss) | F5F5F5 (cream) |

| Coral Energy | F96167 (coral) | F9E795 (gold) | 2F3C7E (navy) |

| Warm Terracotta | B85042 (terracotta) | E7E8D1 (sand) | A7BEAE (sage) |

| Ocean Gradient | 065A82 (deep blue) | 1C7293 (teal) | 21295C (midnight) |

| Charcoal Minimal | 36454F (charcoal) | F2F2F2 (off-white) | 212121 (black) |

| Teal Trust | 028090 (teal) | 00A896 (seafoam) | 02C39A (mint) |

| Berry & Cream | 6D2E46 (berry) | A26769 (dusty rose) | ECE2D0 (cream) |

| Sage Calm | 84B59F (sage) | 69A297 (eucalyptus) | 50808E (slate) |

| Cherry Bold | 990011 (cherry) | FCF6F5 (off-white) | 2F3C7E (navy) |

For Each Slide

Every slide needs a visual element — image, chart, icon, or shape. Text-only slides are forgettable.

Layout options:

Data display:

Visual polish:

Typography

Font names you write into the .pptx are rendered by the user's PowerPoint, not by this environment. Your visual QA renders via LibreOffice, which substitutes fonts it doesn't have — and for some fonts the substitute has different widths, so your QA preview can show text overflow (or fit) that the real deck won't have. To keep your QA trustworthy:

| Element | Size |

|---------|------|

| Slide title | 36-44pt bold |

| Section header | 20-24pt bold |

| Body text | 14-16pt |

| Captions | 10-12pt muted |

Spacing

Avoid (Common Mistakes)

QA (Required)

Your first render usually has a few real issues — overlaps, overflow, misalignment. Find and fix those, re-render only the slides you changed, and stop.

Content QA (required)

python scripts/slide_text.py output.pptx

Check for missing content, typos, wrong order.

When using templates, check for leftover placeholder text:

python scripts/slide_text.py output.pptx | grep -iE "\bx{3,}\b|lorem|ipsum|\bTODO|\[insert|this.*(page|slide).*layout"

If grep returns results, fix them before declaring success.

File QA (required)

python scripts/office/validate.py output.pptx                      # built from scratch
python scripts/office/validate.py output.pptx --original src.pptx  # built from a template

If the deck came from a template, always pass --original. A template may itself

contain parts the XSD rejects, so a bare run can report failures you never caused — and

a genuine regression can hide among them. --original baselines

the schema and slide checks against the template, suppressing errors it already had.

The structural checks — relationships, content types, charts — ignore --original and

report template-inherited problems either way, so read those on their own merits.

pptxgenjs emits chart XML PowerPoint refuses to open, and every other tool

accepts: python-pptx opens those decks, LibreOffice renders them, the XSD

passes them. Every failure names its fix. Fix it in the generator and rebuild.

A pass is not proof of a valid file: validate.py does not catch everything PowerPoint repairs (a chart element repeated past its limit passes); when you delete an animated shape from a template slide, delete the slide's <p:timing> element too (its animations go with it), or PowerPoint offers to repair the deck.

Visual QA (required)

Convert the slides to images (see Converting to Images) and inspect every one. After staring at the generating code you tend to see what you expect rather than what rendered, so look at the images fresh (a subagent works well for this if you have one). User-visible defects to look for:

Converting to Images

Convert presentations to individual slide images for visual inspection:

python scripts/office/soffice.py --headless --convert-to pdf output.pptx
rm -f slide-*.jpg
pdftoppm -jpeg -r 150 output.pdf slide
ls -1 "$PWD"/slide-*.jpg

Pass the absolute paths printed above directly to the view tool. The rm clears stale images from prior runs. pdftoppm zero-pads based on page count: slide-1.jpg for decks under 10 pages, slide-01.jpg for 10-99, slide-001.jpg for 100+.

After fixes, rerun all four commands above — the PDF must be regenerated from the edited .pptx before pdftoppm can reflect your changes.

Dependencies

pptxgenjs (npm, preinstalled — install only if require('pptxgenjs') fails) · python-pptx, Pillow, defusedxml, lxml (pip — slide_text, thumbnail, clean, validate) · LibreOffice (soffice, auto-configured for sandboxed environments via scripts/office/soffice.py) · pdftoppm (Poppler)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.