本文指导如何使用 C# REST API 从 PowerPoint 删除笔记。您将了解**如何使用基于 .NET 的云 SDK 通过 C# 低代码 API 删除 PowerPoint 中的所有注释。它将为您提供删除注释幻灯片并确认注释删除的示例代码。
先决条件
下载 Aspose.Slides Cloud SDK for Dotnet to delete a note
使用上述 SDK 设置 C# 项目以删除注释
使用 C# REST API 从 PowerPoint 中删除所有注释的步骤
- 使用 SlidesApi 类以及用于删除注释的凭据来初始化 API 客户端
- 使用 UploadFile() 方法上传带有注释的演示文稿
- 使用上传的文件名和目标幻灯片编号调用 DeleteNotesSlide() 方法
- 显示消息以表明注释已从目标幻灯片中删除
- 删除注释后下载更新的演示文稿
这些步骤描述如何使用 C# REST 接口删除 PowerPoint 中的注释。将目标演示文稿上传到云存储,并通过提供文件名和目标幻灯片调用DeleteNotesSlide() 方法。对演示文稿中的所有幻灯片重复此过程,并将输出保存在磁盘上。
使用 C# REST 接口删除 PowerPoint 中所有注释的代码
using Aspose.Slides.Cloud.Sdk; | |
using Aspose.Slides.Cloud.Sdk.Model; | |
using System; | |
using System.IO; | |
namespace PresentationModifier | |
{ | |
class SlideNotesRemover | |
{ | |
static void Main(string[] args) | |
{ | |
// Initialize the API client with credentials | |
var slidesApi = new SlidesApi("ID", "Secret"); | |
// Define the presentation file name | |
string presentationFile = "PresentationExample.pptx"; | |
// Upload the presentation to the server | |
var uploadResponse = slidesApi.UploadFile(presentationFile, new MemoryStream(File.ReadAllBytes(presentationFile))); | |
// Specify the slide number to modify (changed to slide 2) | |
int targetSlideNumber = 2; | |
// Remove the notes slide from the specified slide | |
Slide updatedSlide = slidesApi.DeleteNotesSlide(presentationFile, targetSlideNumber); | |
// Check if the notes slide exists after the operation | |
bool isNotesSlidePresent = updatedSlide.NotesSlide != null; | |
Console.WriteLine("Notes slide present: " + isNotesSlidePresent); | |
// Download the updated presentation from the server | |
Stream updatedFileStream = slidesApi.DownloadFile(presentationFile); | |
// Save the modified presentation locally | |
using (var fileStream = new FileStream("ModifiedPresentation.pptx", FileMode.Create, FileAccess.Write)) | |
{ | |
updatedFileStream.CopyTo(fileStream); | |
} | |
Console.WriteLine("Presentation updated and saved as 'ModifiedPresentation.pptx'."); | |
} | |
} | |
} |
此代码演示了如何使用 C# REST 接口删除 PowerPoint 中的注释。您可以使用 NotesSlide 标志来检查某些幻灯片在删除注释之前和之后是否有注释。要检查注释幻灯片是否存在,请使用 NotesSlideExists() 方法。
这篇文章教我们如何删除笔记。要向演示文稿添加注释,请参阅有关 使用 C# REST API 将注释添加到 PowerPoint 幻灯片 的文章。