syncfusion-dotnet-powerpoint

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PowerPoint (PPTX) Presentation Processing

PowerPoint(PPTX)演示文稿处理

Overview

概述

Create, edit and convert PowerPoint (.pptx) files using the Syncfusion Presentation Library. This skill supports two operational modes — generating C# code for the user’s project or executing tasks directly through a CSX script.
使用Syncfusion Presentation Library创建、编辑和转换PowerPoint(.pptx)文件。 此技能支持两种操作模式——为用户项目生成C#代码,或通过CSX脚本直接执行任务。

Key Capabilities

核心功能

  • Create & Edit: Presentations (.pptx), slides (clone and merge), paragraphs, text boxes, tables, shapes, images, lists, connectors, hyperlinks, headers/footers, comments, document properties, sections
  • Advanced Features: Custom animations and slide transitions, master slide layouts, speaker notes, SmartArt, OLE objects, find and replace, macros, chart creation and editing, chart-to-image conversion
  • Conversion: PowerPoint to PDF; PowerPoint to images (PNG, JPEG)
  • Security: Encrypt and decrypt presentations; set and remove write protection
  • 创建与编辑: 演示文稿(.pptx)、幻灯片(克隆与合并)、段落、文本框、表格、形状、图片、列表、连接线、超链接、页眉/页脚、批注、文档属性、节
  • 高级功能: 自定义动画和幻灯片切换效果、母版幻灯片版式、演讲者备注、SmartArt、OLE对象、查找和替换、宏、图表创建与编辑、图表转图片
  • 转换: PowerPoint转PDF;PowerPoint转图片(PNG、JPEG)
  • 安全: 加密和解密演示文稿;设置和移除写保护

Prerequisites

前提条件

Quick Start Examples

快速入门示例

Example 1: Generate Code (Mode 1)

示例1:生成代码(模式1)

User: "Show me how to create a PowerPoint presentation with a simple bar chart"
Result: C# code snippet displayed (no files created)
用户: "展示如何创建包含简单条形图的PowerPoint演示文稿"
结果: 显示C#代码片段(不创建文件)

Example 2: Execute Task (Mode 2)

示例2:执行任务(模式2)

User: "Create a PowerPoint presentation with a simple bar chart at output/SalesChart.pptx"
Result: Physical file created at
output/SalesChart.pptx
with the chart embedded
用户: "在output/SalesChart.pptx路径下创建包含简单条形图的PowerPoint演示文稿"
结果:
output/SalesChart.pptx
路径下创建包含嵌入图表的实体文件

Two Modes — Select Based on User Intent

两种模式——根据用户意图选择

Mode 1: Generate C# Code for the User's Project (default)

模式1:为用户项目生成C#代码(默认)

Use this mode when the user wants to view, write, review, refactor, or modify C# code related to PowerPoint processing.
Trigger keywords: "show me how", "how to", "how can I", "how do I", "provide code", "provide an example", "give an example", "demonstrate", "code snippet", "sample code", "example", "sample", "give me", "show me", "Program.cs", "example code", "generate code for", "codesnippet" .
Workflow:
当用户想要查看、编写、审阅、重构或修改与PowerPoint处理相关的C#代码时,使用此模式。
触发关键词: "show me how"、"how to"、"how can I"、"how do I"、"provide code"、"provide an example"、"give an example"、"demonstrate"、"code snippet"、"sample code"、"example"、"sample"、"give me"、"show me"、"Program.cs"、"example code"、"generate code for"、"codesnippet"。
工作流程:

Step 1 — Detect Application Type and Suggest Required NuGet Packages

步骤1——检测应用类型并建议所需NuGet包

  • Inspect the workspace project files (
    .csproj
    ,
    web.config
    ,
    App.config
    ,
    Startup.cs
    ,
    Program.cs
    , etc.) and use the detection signals table in
    references/nuget-packages.md
    to determine the application type.
  • Based on the detected application type, identify the correct NuGet package(s) from references/nuget-packages.md and instruct the user to install them before generating any code.
  • 检查工作区项目文件(
    .csproj
    web.config
    App.config
    Startup.cs
    Program.cs
    等),使用
    references/nuget-packages.md
    中的检测信号表确定应用类型。
  • 根据检测到的应用类型,从references/nuget-packages.md中识别正确的NuGet包,并指导用户在生成任何代码之前安装它们。

Step 2 — Generate Code from Reference Files Only

步骤2——仅从参考文件生成代码

Do NOT invent, guess, or suggest any API, method, property, class, or namespace not explicitly present in the reference files.
  • Read the relevant
    references/*.md
    file(s) for the requested feature
  • Build C# code strictly from the APIs and snippets found in those files
  • Select the correct snippet variant based on the app type detected in Step 1:
    • Windows-specific apps (WinForms, WPF, .NET Framework Console, ASP.NET MVC4/5 ) → use Windows-specific snippets
    • Cross-platform apps (ASP.NET Core, .NET Core/.NET 5+ Console, Blazor, MAUI) → use cross-platform /
      .Net.Core
      snippets
  • Do not create or run any
    .csx
    script

请勿发明、猜测或建议任何未在参考文件中明确提及的API、方法、属性、类或命名空间。
  • 读取与所需功能相关的
    references/*.md
    文件
  • 严格从这些文件中的API和片段构建C#代码
  • 根据步骤1中检测到的应用类型选择正确的片段变体:
    • Windows专属应用(WinForms、WPF、.NET Framework控制台、ASP.NET MVC4/5)→ 使用Windows专属片段
    • 跨平台应用(ASP.NET Core、.NET Core/.NET 5+控制台、Blazor、MAUI)→ 使用跨平台/
      .Net.Core
      片段
  • 请勿创建或运行任何
    .csx
    脚本

Mode 2: Execute via CSX Script (does not touch project files)

模式2:通过CSX脚本执行(不修改项目文件)

Use this mode only when the user explicitly requests execution, file generation, or a fully produced output (such as a completed PPTX file).
Trigger keywords: "create a presentation", "make a presentation", "generate a presentation", "open", "edit", "modify", "change" a
.pptx
file, "without modifying my project", "run a csx script", or when the user provides a file path (e.g.,
output/report.pptx
).
Workflow:
仅当用户明确要求执行、生成文件或完整输出(如已完成的PPTX文件)时,使用此模式。
触发关键词: "create a presentation"、"make a presentation"、"generate a presentation"、"open"、"edit"、"modify"、"change" a
.pptx
file、"without modifying my project"、"run a csx script",或当用户提供文件路径时(例如
output/report.pptx
)。
工作流程:

Step 1 — Create Temp CSX Script

步骤1——创建临时CSX脚本

  • Start with
    references/template.csx
    as the base
  • Create at:
    {skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx
    (e.g.,
    skill-root
    =
    .codestudio/skills
    )
  • Use random GUID for unique filename (e.g.,
    temp-a3f7b2c1.csx
    ); never create in workspace root
  • references/template.csx
    为基础
  • 创建路径:
    {skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx
    (例如
    skill-root
    =
    .codestudio/skills
  • 使用随机GUID作为唯一文件名(例如
    temp-a3f7b2c1.csx
    );切勿在工作区根目录创建

Step 2 — Build Script from Reference Files

步骤2——从参考文件构建脚本

  • Do NOT invent APIs/methods not in reference files
  • Read relevant
    references/*.md
    file(s) and extract code snippets
  • Replace all placeholders: file paths, document properties, data values, field names, etc.
  • 请勿发明参考文件中未包含的API/方法
  • 读取相关的
    references/*.md
    文件并提取代码片段
  • 替换所有占位符:文件路径、文档属性、数据值、字段名等

Step 3 — Execute Script

步骤3——执行脚本

  • Run:
    dotnet script {skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx
  • Verify successful execution and capture any errors
  • 运行:
    dotnet script {skill-root}/syncfusion-dotnet-powerpoint/scripts/temp-{uniqueId}.csx
  • 验证执行是否成功并捕获任何错误

Step 4 — Clean Up and Report

步骤4——清理并报告

  • Delete the temp
    .csx
    file after execution
  • Report SUCCESS/ERROR with output file path(s) and any error messages with fixes

  • 执行完成后删除临时
    .csx
    文件
  • 报告成功/错误信息,包含输出文件路径及任何错误消息和修复方案

Code References

代码参考

All templates and snippets are in the
references/
folder:
FileContents
template.csxBase CSX script structure (Mode 2 only)
presentation-structure.mdCreate/save/close presentation, slide layout, page size, document properties
slides.mdAdd, remove, resize, and customize PowerPoint slides, print slides
layout.mdAccess, customize, and create master slides and layout slides
paragraph.mdAdd, format, and manage paragraphs in textboxes and shapes
sections.mdCreate and Modify Sections in presentation
tables.mdCreate and modify tables in presentation
shapes.mdAdd, iterate, format, and remove shapes (AutoShapes, pictures, text boxes, group shapes) in a presentation
connectors.mdAdd, edit, update, and remove connectors between shapes
image.mdAdd, replace, crop, and remove images including SVG support
list.mdCreate numbered, bulleted, picture, and multi-level lists
chart.mdCreate and edit chart in presentation
animation-transition.mdAdd, modify slide transition and annimation effect in presentation
comments.mdAdd, Reply, Modify, Delete commments in presentation
header-footer.mdAdd, edit, and remove headers and footers including slide numbers and dates
notes.mdAdd, edit, format, and remove speaker notes in presentations
ole-objects.mdInsert, extract, and manage OLE objects (Excel, Word, Visio) in slides
conversions.mdConvert Presentation to image and Pdf
encrypt-decrypt.mdSecurity: Protect, encrypt, and decrypt during read or write access in presentations
find-and-replace.mdFind and Replace, Find and highlight in specific slide or in presentation
smartart.mdCreate a SmartArt, Add, Edit, Remove nodes in SmartArt in a PowerPoint Presentation
hyperlinks.mdAdd or Modify Web, Email, Bookmark, File, Image hyperlinks
macros.mdLoad, Save, Remove and manage macros in presentations

所有模板和片段都位于
references/
文件夹中:
文件内容
template.csx基础CSX脚本结构(仅模式2可用)
presentation-structure.md创建/保存/关闭演示文稿、幻灯片版式、页面大小、文档属性
slides.md添加、删除、调整大小和自定义PowerPoint幻灯片、打印幻灯片
layout.md访问、自定义和创建母版幻灯片和版式幻灯片
paragraph.md在文本框和形状中添加、格式化和管理段落
sections.md在演示文稿中创建和修改节
tables.md在演示文稿中创建和修改表格
shapes.md在演示文稿中添加、遍历、格式化和删除形状(自选图形、图片、文本框、组合形状)
connectors.md在形状之间添加、编辑、更新和删除连接线
image.md添加、替换、裁剪和删除图片,包括SVG支持
list.md创建编号、项目符号、图片和多级列表
chart.md在演示文稿中创建和编辑图表
animation-transition.md在演示文稿中添加、修改幻灯片切换和动画效果
comments.md在演示文稿中添加、回复、修改、删除批注
header-footer.md添加、编辑和删除页眉和页脚,包括幻灯片编号和日期
notes.md在演示文稿中添加、编辑、格式化和删除演讲者备注
ole-objects.md在幻灯片中插入、提取和管理OLE对象(Excel、Word、Visio)
conversions.md将演示文稿转换为图片和Pdf
encrypt-decrypt.md安全:在演示文稿的读写过程中进行保护、加密和解密
find-and-replace.md在特定幻灯片或整个演示文稿中查找和替换、查找并高亮显示
smartart.md在PowerPoint演示文稿中创建SmartArt、添加、编辑、删除SmartArt节点
hyperlinks.md添加或修改网页、邮件、书签、文件、图片超链接
macros.md在演示文稿中加载、保存、删除和管理宏

Rules

规则

  • Output files go in
    ./output/
    directory
  • Temp
    .csx
    scripts must be created inside
    {skill-root}/syncfusion-dotnet-powerpoint/scripts/
    — never in the workspace root or customer
    scripts/
    folder
  • Use license key from
    SyncfusionLicense.txt
    at workspace root or env var
    SYNCFUSION_LICENSE_KEY
  • Never use Python libraries (e.g., python-pptx)
  • Never leave temp
    .csx
    files after execution
  • 输出文件保存至
    ./output/
    目录
  • 临时
    .csx
    脚本必须在
    {skill-root}/syncfusion-dotnet-powerpoint/scripts/
    目录下创建——切勿在工作区根目录或客户的
    scripts/
    文件夹中创建
  • 使用工作区根目录下的
    SyncfusionLicense.txt
    或环境变量
    SYNCFUSION_LICENSE_KEY
    中的许可证密钥
  • 切勿使用Python库(例如python-pptx)
  • 执行完成后切勿保留临时
    .csx
    文件