pptx-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePPTX 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
快速参考
| Task | Approach |
|---|---|
| Read/analyze content | |
| Edit or create from template | See Editing Presentations |
| Create from scratch | See Creating from Scratch below |
| Item | Value |
|---|---|
| Dimensions | 10" x 5.625" (LAYOUT_16x9) |
| Colors | 6-char hex without # (e.g., |
| English font | Arial (default), or approved alternatives |
| Chinese font | Microsoft YaHei |
| Page badge position | x: 9.3", y: 5.1" |
| Theme keys | |
| Shapes | RECTANGLE, OVAL, LINE, ROUNDED_RECTANGLE |
| Charts | BAR, LINE, PIE, DOUGHNUT, SCATTER, BUBBLE, RADAR |
| 任务 | 实现方式 |
|---|---|
| 读取/分析内容 | |
| 基于模板编辑或创建 | 查看编辑演示文稿 |
| 从头创建 | 查看下方的从头创建工作流 |
| 项目 | 取值 |
|---|---|
| 尺寸 | 10" x 5.625" (LAYOUT_16x9) |
| 颜色 | 6位十六进制值(不带#,例如 |
| 英文字体 | Arial(默认)或经批准的替代字体 |
| 中文字体 | 微软雅黑 |
| 页码标识位置 | x: 9.3", y: 5.1" |
| 主题键 | |
| 形状 | RECTANGLE, OVAL, LINE, ROUNDED_RECTANGLE |
| 图表 | BAR, LINE, PIE, DOUGHNUT, SCATTER, BUBBLE, RADAR |
Reference Files
参考文件
| File | Contents |
|---|---|
| slide-types.md | 5 slide page types (Cover, TOC, Section Divider, Content, Summary) + additional layout patterns |
| design-system.md | Color palettes, font reference, style recipes (Sharp/Soft/Rounded/Pill), typography & spacing |
| editing.md | Template-based editing workflow, XML manipulation, formatting rules, common pitfalls |
| pitfalls.md | QA process, common mistakes, critical PptxGenJS pitfalls |
| pptxgenjs.md | Complete PptxGenJS API reference |
| 文件 | 内容 |
|---|---|
| slide-types.md | 5种幻灯片页面类型(封面、目录、章节分隔页、内容页、摘要页)+ 额外布局模式 |
| design-system.md | 调色板、字体参考、样式方案(Sharp/Soft/Rounded/Pill)、排版与间距规范 |
| editing.md | 基于模板的编辑工作流、XML操作、格式规则、常见问题 |
| pitfalls.md | QA流程、常见错误、PptxGenJS关键注意事项 |
| pptxgenjs.md | 完整的PptxGenJS API参考 |
Reading Content
读取内容
bash
undefinedbash
undefinedText 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 directory. Each file must export a synchronous 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.
slides/createSlide(pres, theme)Tell each subagent:
- File naming: ,
slides/slide-01.js, etc.slides/slide-02.js - Images go in:
slides/imgs/ - Final PPTX goes in:
slides/output/ - Dimensions: 10" x 5.625" (LAYOUT_16x9)
- Fonts: Chinese = Microsoft YaHei, English = Arial (or approved alternative)
- Colors: 6-char hex without # (e.g. )
"FF0000" - Must use the theme object contract (see Theme Object Contract)
- Must follow the PptxGenJS API reference
在目录下为每张幻灯片创建一个JS文件。每个文件必须导出一个同步的函数。遵循幻灯片输出格式以及slide-types.md中的类型特定指导。如果有可用的子代理,可同时生成最多5张幻灯片。
slides/createSlide(pres, theme)告知每个子代理:
- 文件命名:、
slides/slide-01.js等slides/slide-02.js - 图片存放位置:
slides/imgs/ - 最终PPTX文件存放位置:
slides/output/ - 尺寸:10" x 5.625" (LAYOUT_16x9)
- 字体:中文 = 微软雅黑,英文 = Arial(或经批准的替代字体)
- 颜色:6位十六进制值(不带#,例如 )
"FF0000" - 必须使用主题对象约定(参见主题对象约定)
- 必须遵循PptxGenJS API参考
Step 6: Compile into Final PPTX
步骤6:编译为最终PPTX文件
Create to combine all slide modules:
slides/compile.jsjavascript
// 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.jsjavascript
// 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.jsStep 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.pptxslides/
├── slide-01.js # 幻灯片模块
├── slide-02.js
├── ...
├── imgs/ # 幻灯片中使用的图片
└── output/ # 最终产物
└── presentation.pptxSlide 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:
| Key | Purpose | Example |
|---|---|---|
| Darkest color, titles | |
| Dark accent, body text | |
| Mid-tone accent | |
| Light accent | |
| Background color | |
NEVER use other key names like , , , , .
backgroundtextmuteddarkestlightest编译脚本会传递一个包含以下精确键名的主题对象:
| 键名 | 用途 | 示例 |
|---|---|---|
| 最深色,用于标题 | |
| 深色强调色,用于正文文本 | |
| 中间色调强调色 | |
| 浅色强调色 | |
| 背景色 | |
切勿使用其他键名,例如、、、、。
backgroundtextmuteddarkestlightestPage 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. or
3), NOT "3/12"03 - Use palette colors, keep subtle
除封面页外,所有幻灯片必须在右下角包含页码标识。
- 位置:x: 9.3", y: 5.1"
- 仅显示当前页码(例如 或
3),不要显示"3/12"03 - 使用调色板颜色,保持样式简洁
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
依赖项
- — text extraction
pip install "markitdown[pptx]" - — creating from scratch
npm install -g pptxgenjs - — icons (optional)
npm install -g react-icons react react-dom sharp
- — 文本提取
pip install "markitdown[pptx]" - — 从头创建演示文稿
npm install -g pptxgenjs - — 图标(可选)
npm install -g react-icons react react-dom sharp