pptx-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePPTX Generator
PPTX 生成工具
When to Use This Skill
何时使用此技能
Use this skill when:
- Creating presentations programmatically from data or specifications
- Populating branded templates with dynamic content while preserving corporate styling
- Extracting text and structure from existing PPTX files for analysis
- Combining slides from a library of approved templates
- Automating presentation generation workflows
Do NOT use this skill when:
- User wants to open/view presentations (use native PowerPoint or viewer)
- Complex animations or transitions are required (limited support)
- Working with older .ppt format (PPTX only)
在以下场景使用此技能:
- 根据数据或规范以编程方式创建演示文稿
- 为品牌化模板填充动态内容,同时保留企业样式
- 从现有PPTX文件中提取文本和结构用于分析
- 从已批准的模板库中组合幻灯片
- 自动化演示文稿生成工作流
请勿在以下场景使用此技能:
- 用户想要打开/查看演示文稿(使用原生PowerPoint或查看器)
- 需要复杂动画或转场效果(仅支持基础功能)
- 处理旧版.ppt格式(仅支持PPTX)
Prerequisites
前提条件
- Deno installed (https://deno.land/)
- Input PPTX files for template-based operations
- JSON specification for scratch generation
- 已安装Deno(https://deno.land/)
- 用于模板化操作的输入PPTX文件
- 用于从零开始创建的JSON规范
Quick Start
快速开始
Two Modes of Operation
两种操作模式
-
Template Mode: Modify existing branded templates
- Analyze & Replace: Find and replace with content
{{PLACEHOLDERS}} - Slide Library: Select and combine slides from a template library
- Analyze & Replace: Find
-
Scratch Mode: Create presentations from nothing using JSON specifications
-
模板模式:修改现有品牌化模板
- 分析与替换:查找并替换为内容
{{PLACEHOLDERS}} - 幻灯片库:从模板库中选择并组合幻灯片
- 分析与替换:查找
-
从零创建模式:使用JSON规范从头创建演示文稿
Instructions
操作说明
Mode 1: Template-Based Generation
模式1:基于模板的生成
Step 1a: Analyze the Template
步骤1a:分析模板
Extract text inventory to understand what can be replaced:
bash
deno run --allow-read scripts/analyze-template.ts corporate-template.pptx > inventory.jsonOutput (inventory.json):
json
{
"filename": "corporate-template.pptx",
"slideCount": 10,
"textElements": [
{
"slideNumber": 1,
"shapeId": "shape-2",
"shapeName": "Title 1",
"placeholderType": "ctrTitle",
"position": { "x": 1.5, "y": 2.0, "w": 7.0, "h": 1.2 },
"paragraphs": [
{ "text": "{{TITLE}}", "fontSize": 44, "bold": true }
]
}
]
}提取文本清单以了解可替换内容:
bash
deno run --allow-read scripts/analyze-template.ts corporate-template.pptx > inventory.json输出(inventory.json):
json
{
"filename": "corporate-template.pptx",
"slideCount": 10,
"textElements": [
{
"slideNumber": 1,
"shapeId": "shape-2",
"shapeName": "Title 1",
"placeholderType": "ctrTitle",
"position": { "x": 1.5, "y": 2.0, "w": 7.0, "h": 1.2 },
"paragraphs": [
{ "text": "{{TITLE}}", "fontSize": 44, "bold": true }
]
}
]
}Step 1b: Create Replacement Specification
步骤1b:创建替换规范
Create :
replacements.jsonjson
{
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Q4 2024 Results" },
{ "tag": "{{SUBTITLE}}", "value": "Financial Overview" },
{ "tag": "{{DATE}}", "value": "December 2024" },
{ "tag": "{{AUTHOR}}", "value": "Finance Team", "slideNumbers": [1] }
]
}创建:
replacements.jsonjson
{
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Q4 2024 Results" },
{ "tag": "{{SUBTITLE}}", "value": "Financial Overview" },
{ "tag": "{{DATE}}", "value": "December 2024" },
{ "tag": "{{AUTHOR}}", "value": "Finance Team", "slideNumbers": [1] }
]
}Step 1c: Generate Output
步骤1c:生成输出文件
bash
deno run --allow-read --allow-write scripts/generate-from-template.ts \
corporate-template.pptx replacements.json output.pptxbash
deno run --allow-read --allow-write scripts/generate-from-template.ts \
corporate-template.pptx replacements.json output.pptxMode 1 (Alternative): Slide Library
模式1(替代方案):幻灯片库
Step 2a: Preview Template Slides
步骤2a:预览模板幻灯片
Get information about available slides:
bash
deno run --allow-read scripts/generate-thumbnails.ts slide-library.pptxFor visual preview, extract the thumbnail:
bash
deno run --allow-read --allow-write scripts/generate-thumbnails.ts \
slide-library.pptx --extract-thumb --output-dir ./previews获取可用幻灯片的信息:
bash
deno run --allow-read scripts/generate-thumbnails.ts slide-library.pptx如需可视化预览,提取缩略图:
bash
deno run --allow-read --allow-write scripts/generate-thumbnails.ts \
slide-library.pptx --extract-thumb --output-dir ./previewsStep 2b: Select and Combine Slides
步骤2b:选择并组合幻灯片
Create :
selections.jsonjson
{
"slideSelections": [
{ "slideNumber": 1 },
{ "slideNumber": 5 },
{ "slideNumber": 12 },
{ "slideNumber": 3 }
],
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Custom Presentation" }
]
}创建:
selections.jsonjson
{
"slideSelections": [
{ "slideNumber": 1 },
{ "slideNumber": 5 },
{ "slideNumber": 12 },
{ "slideNumber": 3 }
],
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Custom Presentation" }
]
}Step 2c: Generate Combined Presentation
步骤2c:生成组合演示文稿
bash
deno run --allow-read --allow-write scripts/generate-from-template.ts \
slide-library.pptx selections.json custom-deck.pptxbash
deno run --allow-read --allow-write scripts/generate-from-template.ts \
slide-library.pptx selections.json custom-deck.pptxMode 2: From-Scratch Generation
模式2:从零开始创建
Step 3a: Create Specification
步骤3a:创建规范文件
Create :
spec.jsonjson
{
"title": "Product Launch 2025",
"author": "Marketing Team",
"slides": [
{
"background": { "color": "003366" },
"elements": [
{
"type": "text",
"x": 1, "y": 2.5, "w": 8, "h": 1.5,
"options": {
"text": "Product Launch 2025",
"fontSize": 44,
"bold": true,
"color": "FFFFFF",
"align": "center"
}
},
{
"type": "text",
"x": 1, "y": 4, "w": 8, "h": 0.5,
"options": {
"text": "Revolutionizing the Industry",
"fontSize": 24,
"color": "CCCCCC",
"align": "center"
}
}
]
},
{
"elements": [
{
"type": "text",
"x": 0.5, "y": 0.5, "w": 9, "h": 0.7,
"options": {
"text": "Key Features",
"fontSize": 32,
"bold": true,
"color": "003366"
}
},
{
"type": "table",
"x": 0.5, "y": 1.5, "w": 9, "h": 3,
"options": {
"rows": [
["Feature", "Description", "Benefit"],
["Speed", "2x faster processing", "Save time"],
["Quality", "HD output", "Better results"],
["Integration", "Works with existing tools", "Easy adoption"]
],
"border": { "pt": 1, "color": "CCCCCC" }
}
}
]
}
]
}创建:
spec.jsonjson
{
"title": "Product Launch 2025",
"author": "Marketing Team",
"slides": [
{
"background": { "color": "003366" },
"elements": [
{
"type": "text",
"x": 1, "y": 2.5, "w": 8, "h": 1.5,
"options": {
"text": "Product Launch 2025",
"fontSize": 44,
"bold": true,
"color": "FFFFFF",
"align": "center"
}
},
{
"type": "text",
"x": 1, "y": 4, "w": 8, "h": 0.5,
"options": {
"text": "Revolutionizing the Industry",
"fontSize": 24,
"color": "CCCCCC",
"align": "center"
}
}
]
},
{
"elements": [
{
"type": "text",
"x": 0.5, "y": 0.5, "w": 9, "h": 0.7,
"options": {
"text": "Key Features",
"fontSize": 32,
"bold": true,
"color": "003366"
}
},
{
"type": "table",
"x": 0.5, "y": 1.5, "w": 9, "h": 3,
"options": {
"rows": [
["Feature", "Description", "Benefit"],
["Speed", "2x faster processing", "Save time"],
["Quality", "HD output", "Better results"],
["Integration", "Works with existing tools", "Easy adoption"]
],
"border": { "pt": 1, "color": "CCCCCC" }
}
}
]
}
]
}Step 3b: Generate Presentation
步骤3b:生成演示文稿
bash
deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.pptxbash
deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.pptxExamples
示例
Example 1: Corporate Quarterly Report
示例1:企业季度报告
Scenario: Generate quarterly report from branded template.
Steps:
bash
undefined场景:从品牌化模板生成季度报告。
步骤:
bash
undefined1. Analyze template for replaceable content
1. 分析模板中的可替换内容
deno run --allow-read scripts/analyze-template.ts quarterly-template.pptx --pretty
deno run --allow-read scripts/analyze-template.ts quarterly-template.pptx --pretty
2. Create replacements.json with Q4 data
2. 创建包含Q4数据的replacements.json
3. Generate report
3. 生成报告
deno run --allow-read --allow-write scripts/generate-from-template.ts
quarterly-template.pptx replacements.json Q4-2024-Report.pptx
quarterly-template.pptx replacements.json Q4-2024-Report.pptx
undefineddeno run --allow-read --allow-write scripts/generate-from-template.ts
quarterly-template.pptx replacements.json Q4-2024-Report.pptx
quarterly-template.pptx replacements.json Q4-2024-Report.pptx
undefinedExample 2: Custom Pitch Deck from Slide Library
示例2:从幻灯片库创建自定义推介演示文稿
Scenario: Combine approved slides for a specific client pitch.
Steps:
bash
undefined场景:为特定客户组合已批准的幻灯片。
步骤:
bash
undefined1. View available slides
1. 查看可用幻灯片
deno run --allow-read scripts/generate-thumbnails.ts pitch-library.pptx
deno run --allow-read scripts/generate-thumbnails.ts pitch-library.pptx
2. Create selections.json picking slides 1, 3, 7, 12, 15
2. 创建selections.json,选择幻灯片1、3、7、12、15
3. Generate custom deck
3. 生成自定义演示文稿
deno run --allow-read --allow-write scripts/generate-from-template.ts
pitch-library.pptx selections.json acme-pitch.pptx
pitch-library.pptx selections.json acme-pitch.pptx
undefineddeno run --allow-read --allow-write scripts/generate-from-template.ts
pitch-library.pptx selections.json acme-pitch.pptx
pitch-library.pptx selections.json acme-pitch.pptx
undefinedExample 3: Data-Driven Presentation
示例3:数据驱动的演示文稿
Scenario: Generate presentation from JSON data (e.g., API response).
Steps:
bash
undefined场景:从JSON数据(如API响应)生成演示文稿。
步骤:
bash
undefined1. Transform your data into spec.json format
1. 将你的数据转换为spec.json格式
2. Generate presentation
2. 生成演示文稿
deno run --allow-read --allow-write scripts/generate-scratch.ts data-spec.json report.pptx
undefineddeno run --allow-read --allow-write scripts/generate-scratch.ts data-spec.json report.pptx
undefinedScript Reference
脚本参考
| Script | Purpose | Permissions |
|---|---|---|
| Extract text inventory from PPTX | |
| Get slide info and extract previews | |
| Modify templates (replace/combine) | |
| Create PPTX from JSON specification | |
| 脚本 | 用途 | 权限 |
|---|---|---|
| 从PPTX中提取文本清单 | |
| 获取幻灯片信息并提取预览图 | |
| 修改模板(替换/组合) | |
| 从JSON规范创建PPTX | |
Element Types (Scratch Mode)
元素类型(从零创建模式)
| Type | Description | Key Options |
|---|---|---|
| Text box | |
| Image from file or base64 | |
| Data table | |
| Geometric shapes | |
| Charts and graphs | |
| 类型 | 描述 | 关键选项 |
|---|---|---|
| 文本框 | |
| 来自文件或base64的图片 | |
| 数据表 | |
| 几何形状 | |
| 图表和图形 | |
Common Issues and Solutions
常见问题与解决方案
Issue: Text not being replaced
问题:文本未被替换
Symptoms: Output PPTX still contains tags.
{{PLACEHOLDER}}Solution:
- Run to verify exact tag text
analyze-template.ts - Tags may be split across XML runs - ensure your template has tags in single text runs
- Check filter in replacements
slideNumbers
症状:输出的PPTX仍包含标签。
{{PLACEHOLDER}}解决方案:
- 运行验证标签的准确文本
analyze-template.ts - 标签可能被拆分到XML运行段中 - 确保模板中的标签位于单个文本运行段内
- 检查替换内容中的过滤器
slideNumbers
Issue: Slide order incorrect
问题:幻灯片顺序错误
Symptoms: Slides appear in wrong order after combining.
Solution:
- Slides are added in the order specified in
slideSelections - Verify slide numbers match original template (1-indexed)
症状:组合后幻灯片顺序不正确。
解决方案:
- 幻灯片会按照中指定的顺序添加
slideSelections - 验证幻灯片编号与原始模板匹配(从1开始索引)
Issue: Images not appearing
问题:图片未显示
Symptoms: Image elements are blank in output.
Solution:
- Use absolute paths or paths relative to spec.json location
- Verify image file exists and is readable
- Check supported formats: PNG, JPEG, GIF
症状:输出中的图片元素为空。
解决方案:
- 使用绝对路径或相对于spec.json位置的相对路径
- 验证图片文件存在且可读取
- 检查支持的格式:PNG、JPEG、GIF
OOXML Placeholder Inheritance (Advanced)
OOXML占位符继承(高级内容)
Understanding how PowerPoint's OOXML format handles placeholders is crucial for template development.
了解PowerPoint的OOXML格式如何处理占位符对于模板开发至关重要。
The Inheritance Chain
继承链
PowerPoint uses a hierarchical inheritance model:
Theme → Slide Master → Slide Layout → Slide- Theme: Defines colors, fonts, effects
- Slide Master: Defines default placeholder positions and formatting (including bullets)
- Slide Layout: Overrides master settings for specific layout types (e.g., Title Slide, Content)
- Slide: Contains actual content, inherits formatting from layout
PowerPoint使用分层继承模型:
主题 → 幻灯片母版 → 幻灯片版式 → 幻灯片- 主题:定义颜色、字体、效果
- 幻灯片母版:定义占位符的默认位置和格式(包括项目符号)
- 幻灯片版式:为特定版式类型(如标题幻灯片、内容幻灯片)覆盖母版设置
- 幻灯片:包含实际内容,从版式继承格式
Key Principles
核心原则
-
Text Content Does NOT Inherit: Slides must contain their own text content. Thetext in a layout does NOT automatically appear on slides using that layout.
{{placeholder}} -
Text Formatting CAN Inherit: When a slide shape has an empty, it inherits formatting (color, size, bullets) from the layout's
<a:lstStyle/>.<a:lstStyle> -
Placeholder Linking: Slides link to layouts via. The
<p:ph type="..." idx="..."/>(e.g., "title", "body", "ctrTitle") andtypemust match.idx -
Bullet Suppression: To prevent bullets on a placeholder that would normally inherit them from the master's bodyStyle, addin the layout's lstStyle.
<a:buNone/>
-
文本内容不继承:幻灯片必须包含自己的文本内容。版式中的文本不会自动显示在使用该版式的幻灯片上。
{{placeholder}} -
文本格式可继承:当幻灯片形状包含空的时,它会从版式的
<a:lstStyle/>继承格式(颜色、大小、项目符号)。<a:lstStyle> -
占位符链接:幻灯片通过链接到版式。
<p:ph type="..." idx="..."/>(如"title"、"body"、"ctrTitle")和type必须匹配。idx -
项目符号抑制:若要防止占位符从母版的bodyStyle继承项目符号,可在版式的lstStyle中添加。
<a:buNone/>
Defining Inheritable Formatting
定义可继承格式
In layout placeholders, define colors in (inheritable), not in (run-specific):
<a:lstStyle><a:rPr>xml
<!-- Layout: Color in lstStyle (GOOD - inheritable) -->
<p:txBody>
<a:lstStyle>
<a:lvl1pPr algn="ctr">
<a:buNone/> <!-- Suppress bullets -->
<a:defRPr sz="4400" b="1">
<a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill>
</a:defRPr>
</a:lvl1pPr>
</a:lstStyle>
<a:p>
<a:r><a:rPr lang="en-US"/><a:t>{{placeholder}}</a:t></a:r>
</a:p>
</p:txBody>在版式占位符中,在中定义颜色(可继承),而非在中(运行段特定):
<a:lstStyle><a:rPr>xml
<!-- 版式:在lstStyle中定义颜色(推荐 - 可继承) -->
<p:txBody>
<a:lstStyle>
<a:lvl1pPr algn="ctr">
<a:buNone/> <!-- 抑制项目符号 -->
<a:defRPr sz="4400" b="1">
<a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill>
</a:defRPr>
</a:lvl1pPr>
</a:lstStyle>
<a:p>
<a:r><a:rPr lang="en-US"/><a:t>{{placeholder}}</a:t></a:r>
</a:p>
</p:txBody>Slide Shape Structure
幻灯片形状结构
For slides to properly inherit from layouts:
xml
<!-- Slide: Empty lstStyle to inherit from layout -->
<p:sp>
<p:nvSpPr>
<p:cNvPr id="2" name="title 2"/>
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
<p:nvPr>
<p:ph type="ctrTitle"/> <!-- Links to layout placeholder -->
</p:nvPr>
</p:nvSpPr>
<p:spPr/> <!-- Empty = inherit position from layout -->
<p:txBody>
<a:bodyPr/>
<a:lstStyle/> <!-- Empty = inherit formatting from layout -->
<a:p>
<a:r>
<a:rPr lang="en-US"/> <!-- Empty = inherit character formatting -->
<a:t>{{placeholder}}</a:t> <!-- Content must be here -->
</a:r>
</a:p>
</p:txBody>
</p:sp>为使幻灯片正确从版式继承格式:
xml
<!-- 幻灯片:空lstStyle以从版式继承 -->
<p:sp>
<p:nvSpPr>
<p:cNvPr id="2" name="title 2"/>
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
<p:nvPr>
<p:ph type="ctrTitle"/> <!-- 链接到版式占位符 -->
</p:nvPr>
</p:nvSpPr>
<p:spPr/> <!-- 空值 = 从版式继承位置 -->
<p:txBody>
<a:bodyPr/>
<a:lstStyle/> <!-- 空值 = 从版式继承格式 -->
<a:p>
<a:r>
<a:rPr lang="en-US"/> <!-- 空值 = 继承字符格式 -->
<a:t>{{placeholder}}</a:t> <!-- 内容必须在此处 -->
</a:r>
</a:p>
</p:txBody>
</p:sp>Common Issues
常见问题
| Issue | Cause | Solution |
|---|---|---|
| Text shows as black instead of white | Color defined in | Move color to layout's |
| Unwanted bullets appearing | Master's bodyStyle has bullets, layout doesn't override | Add |
| Placeholder text not appearing | Text only in layout, not in slide | Include text content in slide's |
| Formatting not applying | Slide has explicit formatting | Use empty |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 文本显示为黑色而非白色 | 颜色定义在 | 将颜色移至版式 |
| 出现不需要的项目符号 | 母版的bodyStyle包含项目符号,版式未覆盖 | 在版式的 |
| 占位符文本未显示 | 文本仅存在于版式中,未在幻灯片中 | 在幻灯片的 |
| 格式未应用 | 幻灯片包含显式格式 | 使用空的 |
Reference: Placeholder Types
参考:占位符类型
| Type | Usage |
|---|---|
| Centered title (title slides) |
| Standard title |
| Subtitle |
| Content area (use |
| Picture placeholder |
| Date/time |
| Footer |
| Slide number |
| 类型 | 用途 |
|---|---|
| 居中标题(标题幻灯片) |
| 标准标题 |
| 副标题 |
| 内容区域(多个时使用 |
| 图片占位符 |
| 日期/时间 |
| 页脚 |
| 幻灯片编号 |
Limitations
局限性
- No slide rendering: Cannot render slides to images directly (use LibreOffice for this)
- Limited animation support: Basic animations only in scratch mode
- No master slide editing: Template mode preserves but doesn't modify masters
- PPTX only: Does not support legacy .ppt format
- Text run splitting: Complex formatting in templates may split tags across XML elements
- 无幻灯片渲染:无法直接将幻灯片渲染为图片(可使用LibreOffice完成此操作)
- 有限的动画支持:从零创建模式仅支持基础动画
- 无法编辑母版幻灯片:模板模式保留但不修改母版
- 仅支持PPTX:不支持旧版.ppt格式
- 文本运行段拆分:模板中的复杂格式可能将标签拆分到多个XML元素中
Related Skills
相关技能
- pdf-generator: For creating PDF documents instead of presentations
- docx-generator: For creating Word documents
- xlsx-generator: For creating Excel spreadsheets
- pdf-generator:用于创建PDF文档而非演示文稿
- docx-generator:用于创建Word文档
- xlsx-generator:用于创建Excel电子表格