pptx-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PPTX Generator & Editor

PPTX 生成器与编辑器

Overview

概述

This skill handles all PowerPoint tasks: reading/analyzing existing presentations, editing template-based decks via XML manipulation, and creating presentations from scratch using PptxGenJS. It includes a complete design system (color palettes, fonts, style recipes) and detailed guidance for every slide type.
本技能可处理所有PowerPoint相关任务:读取/分析现有演示文稿、通过XML操作编辑基于模板的演示文档,以及使用PptxGenJS从头创建演示文稿。它包含一套完整的设计系统(调色板、字体、样式方案),并为每种幻灯片类型提供详细指导。

Quick Reference

快速参考

TaskApproach
Read/analyze content
python -m markitdown presentation.pptx
Edit or create from templateSee Editing Presentations
Create from scratchSee Creating from Scratch below
ItemValue
Dimensions10" x 5.625" (LAYOUT_16x9)
Colors6-char hex without # (e.g.,
"FF0000"
)
English fontArial (default), or approved alternatives
Chinese fontMicrosoft YaHei
Page badge positionx: 9.3", y: 5.1"
Theme keys
primary
,
secondary
,
accent
,
light
,
bg
ShapesRECTANGLE, OVAL, LINE, ROUNDED_RECTANGLE
ChartsBAR, LINE, PIE, DOUGHNUT, SCATTER, BUBBLE, RADAR
任务实现方式
读取/分析内容
python -m markitdown presentation.pptx
基于模板编辑或创建查看编辑演示文稿
从头创建查看下方的从头创建工作流
项目取值
尺寸10" x 5.625" (LAYOUT_16x9)
颜色6位十六进制值(不带#,例如
"FF0000"
英文字体Arial(默认)或经批准的替代字体
中文字体微软雅黑
页码标识位置x: 9.3", y: 5.1"
主题键
primary
,
secondary
,
accent
,
light
,
bg
形状RECTANGLE, OVAL, LINE, ROUNDED_RECTANGLE
图表BAR, LINE, PIE, DOUGHNUT, SCATTER, BUBBLE, RADAR

Reference Files

参考文件

FileContents
slide-types.md5 slide page types (Cover, TOC, Section Divider, Content, Summary) + additional layout patterns
design-system.mdColor palettes, font reference, style recipes (Sharp/Soft/Rounded/Pill), typography & spacing
editing.mdTemplate-based editing workflow, XML manipulation, formatting rules, common pitfalls
pitfalls.mdQA process, common mistakes, critical PptxGenJS pitfalls
pptxgenjs.mdComplete PptxGenJS API reference

文件内容
slide-types.md5种幻灯片页面类型(封面、目录、章节分隔页、内容页、摘要页)+ 额外布局模式
design-system.md调色板、字体参考、样式方案(Sharp/Soft/Rounded/Pill)、排版与间距规范
editing.md基于模板的编辑工作流、XML操作、格式规则、常见问题
pitfalls.mdQA流程、常见错误、PptxGenJS关键注意事项
pptxgenjs.md完整的PptxGenJS API参考

Reading Content

读取内容

bash
undefined
bash
undefined

Text extraction

文本提取

python -m markitdown presentation.pptx

---
python -m markitdown presentation.pptx

---

Creating from Scratch — Workflow

从头创建 — 工作流

Use when no template or reference presentation is available.
当没有模板或参考演示文稿时使用此方式。

Step 1: Research & Requirements

步骤1:调研与需求分析

Search to understand user requirements — topic, audience, purpose, tone, content depth.
通过搜索了解用户需求——主题、受众、用途、语气、内容深度。

Step 2: Select Color Palette & Fonts

步骤2:选择调色板与字体

Use the Color Palette Reference to select a palette matching the topic and audience. Use the Font Reference to choose a font pairing.
使用调色板参考选择符合主题和受众的调色板。使用字体参考选择字体组合。

Step 3: Select Design Style

步骤3:选择设计风格

Use the Style Recipes to choose a visual style (Sharp, Soft, Rounded, or Pill) matching the presentation tone.
使用样式方案选择与演示文稿语气匹配的视觉风格(Sharp、Soft、Rounded或Pill)。

Step 4: Plan Slide Outline

步骤4:规划幻灯片大纲

Classify every slide as exactly one of the 5 page types. Plan the content and layout for each slide. Ensure visual variety — do NOT repeat the same layout across slides.
每一张幻灯片准确归类为5种页面类型中的一种。规划每张幻灯片的内容和布局。确保视觉多样性——不要在多张幻灯片中重复使用相同布局。

Step 5: Generate Slide JS Files

步骤5:生成幻灯片JS文件

Create one JS file per slide in
slides/
directory. Each file must export a synchronous
createSlide(pres, theme)
function. Follow the Slide Output Format and the type-specific guidance in slide-types.md. Generate up to 5 slides concurrently using subagents if available.
Tell each subagent:
  1. File naming:
    slides/slide-01.js
    ,
    slides/slide-02.js
    , etc.
  2. Images go in:
    slides/imgs/
  3. Final PPTX goes in:
    slides/output/
  4. Dimensions: 10" x 5.625" (LAYOUT_16x9)
  5. Fonts: Chinese = Microsoft YaHei, English = Arial (or approved alternative)
  6. Colors: 6-char hex without # (e.g.
    "FF0000"
    )
  7. Must use the theme object contract (see Theme Object Contract)
  8. Must follow the PptxGenJS API reference
slides/
目录下为每张幻灯片创建一个JS文件。每个文件必须导出一个同步的
createSlide(pres, theme)
函数。遵循幻灯片输出格式以及slide-types.md中的类型特定指导。如果有可用的子代理,可同时生成最多5张幻灯片。
告知每个子代理:
  1. 文件命名:
    slides/slide-01.js
    slides/slide-02.js
  2. 图片存放位置:
    slides/imgs/
  3. 最终PPTX文件存放位置:
    slides/output/
  4. 尺寸:10" x 5.625" (LAYOUT_16x9)
  5. 字体:中文 = 微软雅黑,英文 = Arial(或经批准的替代字体)
  6. 颜色:6位十六进制值(不带#,例如
    "FF0000"
  7. 必须使用主题对象约定(参见主题对象约定
  8. 必须遵循PptxGenJS API参考

Step 6: Compile into Final PPTX

步骤6:编译为最终PPTX文件

Create
slides/compile.js
to combine all slide modules:
javascript
// slides/compile.js
const pptxgen = require('pptxgenjs');
const pres = new pptxgen();
pres.layout = 'LAYOUT_16x9';

const theme = {
  primary: "22223b",    // dark color for backgrounds/text
  secondary: "4a4e69",  // secondary accent
  accent: "9a8c98",     // highlight color
  light: "c9ada7",      // light accent
  bg: "f2e9e4"          // background color
};

for (let i = 1; i <= 12; i++) {  // adjust count as needed
  const num = String(i).padStart(2, '0');
  const slideModule = require(`./slide-${num}.js`);
  slideModule.createSlide(pres, theme);
}

pres.writeFile({ fileName: './output/presentation.pptx' });
Run with:
cd slides && node compile.js
创建
slides/compile.js
以合并所有幻灯片模块:
javascript
// slides/compile.js
const pptxgen = require('pptxgenjs');
const pres = new pptxgen();
pres.layout = 'LAYOUT_16x9';

const theme = {
  primary: "22223b",    // 背景/文本用深色
  secondary: "4a4e69",  // 次要强调色
  accent: "9a8c98",     // 高亮色
  light: "c9ada7",      // 浅色强调色
  bg: "f2e9e4"          // 背景色
};

for (let i = 1; i <= 12; i++) {  // 根据需要调整数量
  const num = String(i).padStart(2, '0');
  const slideModule = require(`./slide-${num}.js`);
  slideModule.createSlide(pres, theme);
}

pres.writeFile({ fileName: './output/presentation.pptx' });
运行命令:
cd slides && node compile.js

Step 7: QA (Required)

步骤7:QA(必填)

See QA Process.
参见QA流程

Output Structure

输出结构

slides/
├── slide-01.js          # Slide modules
├── slide-02.js
├── ...
├── imgs/                # Images used in slides
└── output/              # Final artifacts
    └── presentation.pptx

slides/
├── slide-01.js          # 幻灯片模块
├── slide-02.js
├── ...
├── imgs/                # 幻灯片中使用的图片
└── output/              # 最终产物
    └── presentation.pptx

Slide Output Format

幻灯片输出格式

Each slide is a complete, runnable JS file:
javascript
// slide-01.js
const pptxgen = require("pptxgenjs");

const slideConfig = {
  type: 'cover',
  index: 1,
  title: 'Presentation Title'
};

// MUST be synchronous (not async)
function createSlide(pres, theme) {
  const slide = pres.addSlide();
  slide.background = { color: theme.bg };

  slide.addText(slideConfig.title, {
    x: 0.5, y: 2, w: 9, h: 1.2,
    fontSize: 48, fontFace: "Arial",
    color: theme.primary, bold: true, align: "center"
  });

  return slide;
}

// Standalone preview - use slide-specific filename
if (require.main === module) {
  const pres = new pptxgen();
  pres.layout = 'LAYOUT_16x9';
  const theme = {
    primary: "22223b",
    secondary: "4a4e69",
    accent: "9a8c98",
    light: "c9ada7",
    bg: "f2e9e4"
  };
  createSlide(pres, theme);
  pres.writeFile({ fileName: "slide-01-preview.pptx" });
}

module.exports = { createSlide, slideConfig };

每张幻灯片都是一个完整可运行的JS文件
javascript
// slide-01.js
const pptxgen = require("pptxgenjs");

const slideConfig = {
  type: 'cover',
  index: 1,
  title: 'Presentation Title'
};

// 必须为同步函数(不能是async)
function createSlide(pres, theme) {
  const slide = pres.addSlide();
  slide.background = { color: theme.bg };

  slide.addText(slideConfig.title, {
    x: 0.5, y: 2, w: 9, h: 1.2,
    fontSize: 48, fontFace: "Arial",
    color: theme.primary, bold: true, align: "center"
  });

  return slide;
}

// 独立预览 - 使用幻灯片特定文件名
if (require.main === module) {
  const pres = new pptxgen();
  pres.layout = 'LAYOUT_16x9';
  const theme = {
    primary: "22223b",
    secondary: "4a4e69",
    accent: "9a8c98",
    light: "c9ada7",
    bg: "f2e9e4"
  };
  createSlide(pres, theme);
  pres.writeFile({ fileName: "slide-01-preview.pptx" });
}

module.exports = { createSlide, slideConfig };

Theme Object Contract (MANDATORY)

主题对象约定(必填)

The compile script passes a theme object with these exact keys:
KeyPurposeExample
theme.primary
Darkest color, titles
"22223b"
theme.secondary
Dark accent, body text
"4a4e69"
theme.accent
Mid-tone accent
"9a8c98"
theme.light
Light accent
"c9ada7"
theme.bg
Background color
"f2e9e4"
NEVER use other key names like
background
,
text
,
muted
,
darkest
,
lightest
.

编译脚本会传递一个包含以下精确键名的主题对象:
键名用途示例
theme.primary
最深色,用于标题
"22223b"
theme.secondary
深色强调色,用于正文文本
"4a4e69"
theme.accent
中间色调强调色
"9a8c98"
theme.light
浅色强调色
"c9ada7"
theme.bg
背景色
"f2e9e4"
切勿使用其他键名,例如
background
text
muted
darkest
lightest

Page Number Badge (REQUIRED)

页码标识(必填)

All slides except Cover Page MUST include a page number badge in the bottom-right corner.
  • Position: x: 9.3", y: 5.1"
  • Show current number only (e.g.
    3
    or
    03
    ), NOT "3/12"
  • Use palette colors, keep subtle
除封面页外,所有幻灯片必须在右下角包含页码标识。
  • 位置:x: 9.3", y: 5.1"
  • 仅显示当前页码(例如
    3
    03
    ),不要显示"3/12"
  • 使用调色板颜色,保持样式简洁

Circle Badge (Default)

圆形标识(默认)

javascript
slide.addShape(pres.shapes.OVAL, {
  x: 9.3, y: 5.1, w: 0.4, h: 0.4,
  fill: { color: theme.accent }
});
slide.addText("3", {
  x: 9.3, y: 5.1, w: 0.4, h: 0.4,
  fontSize: 12, fontFace: "Arial",
  color: "FFFFFF", bold: true,
  align: "center", valign: "middle"
});
javascript
slide.addShape(pres.shapes.OVAL, {
  x: 9.3, y: 5.1, w: 0.4, h: 0.4,
  fill: { color: theme.accent }
});
slide.addText("3", {
  x: 9.3, y: 5.1, w: 0.4, h: 0.4,
  fontSize: 12, fontFace: "Arial",
  color: "FFFFFF", bold: true,
  align: "center", valign: "middle"
});

Pill Badge

胶囊形标识

javascript
slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
  x: 9.1, y: 5.15, w: 0.6, h: 0.35,
  fill: { color: theme.accent },
  rectRadius: 0.15
});
slide.addText("03", {
  x: 9.1, y: 5.15, w: 0.6, h: 0.35,
  fontSize: 11, fontFace: "Arial",
  color: "FFFFFF", bold: true,
  align: "center", valign: "middle"
});

javascript
slide.addShape(pres.shapes.ROUNDED_RECTANGLE, {
  x: 9.1, y: 5.15, w: 0.6, h: 0.35,
  fill: { color: theme.accent },
  rectRadius: 0.15
});
slide.addText("03", {
  x: 9.1, y: 5.15, w: 0.6, h: 0.35,
  fontSize: 11, fontFace: "Arial",
  color: "FFFFFF", bold: true,
  align: "center", valign: "middle"
});

Dependencies

依赖项

  • pip install "markitdown[pptx]"
    — text extraction
  • npm install -g pptxgenjs
    — creating from scratch
  • npm install -g react-icons react react-dom sharp
    — icons (optional)
  • pip install "markitdown[pptx]"
    — 文本提取
  • npm install -g pptxgenjs
    — 从头创建演示文稿
  • npm install -g react-icons react react-dom sharp
    — 图标(可选)