How to Create PowerPoint Presentations Using the pptx Skill
The pptx skill in the anthropics/skills repository provides two complementary workflows for generating PowerPoint decks: programmatic creation from scratch using PptxGenJS (JavaScript) and template-based editing via Python XML manipulation.
The pptx skill enables developers and AI systems to automate PowerPoint generation through code. Whether you need to build presentations programmatically with full control over layout and animation, or modify existing brand-compliant templates, this skill offers robust tools for both approaches as documented in skills/pptx/SKILL.md.
Prerequisites and Dependencies
Before you create PowerPoint presentations using the pptx skill, ensure your environment meets the runtime requirements:
- Node.js (≥ 14) with
npm install -g pptxgenjsfor JavaScript generation - Python 3.9+ with
pip install "markitdown[pptx]" Pillowfor template editing - LibreOffice (
soffice) and Poppler (pdftoppm) for PDF conversion and thumbnail generation
Programmatic Creation with PptxGenJS (JavaScript)
The JavaScript workflow leverages the PptxGenJS library to build presentations entirely in code. This approach, documented in skills/pptx/pptxgenjs.md, is ideal when you require full programmatic control over layouts, colors, and animations without an existing template.
Initializing the Presentation
Create a new presentation object and configure its properties:
const pptxgen = require("pptxgenjs");
let pres = new pptxgen();
pres.layout = "LAYOUT_16x9"; // 16:9 widescreen
pres.author = "Your Name";
pres.title = "Quarterly Review";
Adding Content and Saving
Add slides with text, shapes, and formatting, then write the file:
// Add a title slide
let titleSlide = pres.addSlide();
titleSlide.addText("Q2 2025 Review", {
x: 1, y: 1, w: 8, h: 2,
fontSize: 44, bold: true, color: "363636", align: "center"
});
// Add bullet points
let bulletSlide = pres.addSlide();
bulletSlide.addText([
{ text: "Key Achievements", options: { bold: true, fontSize: 32 } },
{ text: " • Revenue +15%", options: { bullet: true, fontSize: 24 } },
{ text: " • New product launch", options: { bullet: true, fontSize: 24 } }
], { x: 0.5, y: 1, w: 9, h: 4, color: "363636" });
// Save the file
pres.writeFile({ fileName: "Quarterly_Review.pptx" });
Run the script with node your-script.js to generate a standard Open XML .pptx file compatible with any PowerPoint client.
Template-Based Editing with Python
For scenarios requiring modification of existing decks—such as updating brand-compliant templates—the Python workflow provides granular XML-level control. This approach treats .pptx files as ZIP archives of XML documents, as detailed in skills/pptx/editing.md.
The XML Unpack-Edit-Pack Workflow
The Python scripts in skills/pptx/scripts/ implement a linear pipeline:
unpack.pyextracts the.pptxarchive and pretty-prints XML filesadd_slide.pyduplicates existing slides while updating relationship tablesclean.pyremoves orphaned media and stale relationship entriespack.pyrecompresses the modified XML into a valid.pptxwith optional XSD validation
Step-by-Step Template Modification
Execute the workflow from your terminal:
# 1. Extract the template
python scripts/office/unpack.py template.pptx unpacked/
# 2. (Optional) Generate thumbnails for visual reference
python scripts/thumbnail.py template.pptx
# 3. Duplicate a slide
python scripts/add_slide.py unpacked/ slide2.xml
# 4. Edit slide XML directly (e.g., modify <a:t> text elements)
# Edit unpacked/ppt/slides/slide2.xml with your changes
# 5. Clean orphaned media
python scripts/clean.py unpacked/
# 6. Repack into final presentation
python scripts/office/pack.py unpacked/ output.pptx --original template.pptx
All scripts utilize defusedxml for secure XML parsing and Pillow for image operations.
Visual QA and Thumbnail Generation
After creating or editing presentations, use scripts/thumbnail.py to generate visual previews. This script converts the deck to PDF via LibreOffice, then creates JPEG thumbnails using pdftoppm:
python scripts/thumbnail.py output.pptx mydeck
The command produces mydeck.jpg (or numbered variants for large decks), providing a grid view for layout verification before delivery.
Summary
- The pptx skill offers two distinct workflows: JavaScript creation via PptxGenJS for scratch builds, and Python XML editing for template modifications.
- JavaScript generation requires Node.js ≥14 and uses
pptxgen = require("pptxgenjs")withpres.writeFile()to output standard Open XML files. - Python editing relies on
unpack.py,add_slide.py,clean.py, andpack.pyto manipulate the underlying ZIP/XML structure safely. - Visual QA is supported through
thumbnail.py, which leverages LibreOffice and Poppler to generate preview grids. - All workflows are documented in
SKILL.md,pptxgenjs.md, andediting.mdwithin theskills/pptx/directory.
Frequently Asked Questions
What is the difference between the JavaScript and Python workflows in the pptx skill?
The JavaScript workflow uses PptxGenJS to create presentations programmatically from scratch, offering complete control over layouts, colors, and animations without needing an existing file. The Python workflow modifies existing .pptx templates by unpacking them into XML, editing the structure, and repacking—ideal for updating brand-compliant templates or making surgical changes to existing slides.
How do I install the required dependencies for the pptx skill?
For JavaScript creation, install Node.js ≥14 and run npm install -g pptxgenjs. For Python editing, install Python 3.9+ and run pip install "markitdown[pptx]" Pillow. Additionally, install LibreOffice (soffice) and Poppler (pdftoppm) for PDF conversion and thumbnail generation capabilities.
Can I add animations to slides using the pptx skill?
Yes, but only through the JavaScript PptxGenJS workflow. The library supports animation configurations when building presentations from scratch. The Python template-editing workflow focuses on static content modification through XML manipulation and does not provide high-level animation APIs.
How do I verify that my edited PowerPoint file is valid before sharing?
After using pack.py to rebuild your presentation, run python -m markitdown output.pptx to extract and verify the text content. For visual validation, execute python scripts/thumbnail.py output.pptx to generate a JPEG grid of all slides, allowing you to spot layout issues before distribution.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →