按照本文使用 C# REST API 向 PowerPoint 添加评论。您将学习使用基于 .NET 的 Cloud SDK 使用 C# Low Code API 自动添加 PowerPoint 评论。它将分享在将评论添加到幻灯片之前设置评论各种参数的详细信息。
先决条件
下载 Aspose.Slides Cloud SDK for Dotnet for inserting comments in the slides
使用上述 SDK 设置 C# 项目,为幻灯片添加评论
使用基于 C# .NET 的 API 对 PowerPoint 演示文稿进行评论的步骤
- 通过设置添加评论的客户端 ID 和密钥来创建 SlidesApi 对象
- 设置输入演示文稿文件名和目标幻灯片索引
- 定义幻灯片评论和相关子评论集合
- 使用 CreateComment 方法向幻灯片添加评论
- 获取评论数以确认添加评论
- 下载包含新评论的更新后的演示文稿文件
这些步骤描述了如何使用 C# RESTful 服务在 PowerPoint 中添加注释。设置输入演示文稿文件名和幻灯片索引,创建幻灯片注释和子注释,然后通过设置输入文件名、目标索引和注释来调用 CreateComment() 方法插入注释。此调用上传演示文稿,在云中对其进行修改,并返回注释集合。
使用 C# REST API 添加 PowerPoint 演示文稿注释的代码
using Aspose.Slides.Cloud.Sdk; | |
using Aspose.Slides.Cloud.Sdk.Model; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
namespace AsposeTestCodes | |
{ | |
class Program | |
{ | |
static void Main(string[] args) // For adding comments | |
{ | |
SlidesApi api = new SlidesApi("ID", "Secret");// For commenting the slides | |
SlideComment comment = new SlideComment {Text = "Master comment here.", Author = "Mr. John"}; | |
var subComments = new List<SlideCommentBase> { new SlideComment | |
{ Text = "Here is the sub-comment.", Author = "Author name here"}}; | |
comment.ChildComments = subComments; | |
SlideComments comments = api.CreateComment("Input.pptx", 3, comment); | |
// System.Console.WriteLine("Total Comments: " + comments.List.Count); | |
// Retrieve the updated file | |
var stream = api.DownloadFile("Input.pptx"); | |
var fStream = new FileStream("NormalComments.pptx", | |
FileMode.Create, FileAccess.Write);// Output file name and mode | |
stream.CopyTo(fStream);// Output file will be generated here | |
} | |
} | |
} |
此代码演示了如何使用 C# RESTful 服务向 PowerPoint 演示文稿添加注释。您可以通过添加注释列表并将其设置为属性 ChildComments,在主注释下添加多个子注释。您可以通过使用 SlideComment 方法设置其他公开的属性来自定义注释。
本文教我们如何在幻灯片中添加注释。您可以按照文章 使用 C# REST API 在 PowerPoint 中使用图片作为背景 为演示文稿插入图像背景。