使用 C# REST API 从演示文稿中删除水印

本文指导如何使用 C# REST API presentation 中删除水印。您将了解如何使用 C# 低代码 API 在 PowerPoint 中删除水印,使用基于 .NET 的 SDK 中的几个 API 调用。示例代码还将演示如何从 API 响应创建输出文件。

先决条件

使用 C# REST API 从 PPT 中删除水印的步骤

  1. 创建 SlidesApi 类的实例以删除水印
  2. 设置输入和输出演示文件名
  3. 将输入文件读入内存流
  4. 使用输入演示文件流调用 DeleteWatermarkOnline() 方法
  5. 将响应中的内存流保存到本地磁盘

这些步骤总结了如何使用 C# REST API 从 PowerPoint 中删除水印。将输入演示加载到流中并使用输入流调用DeleteWatermarkOnline() 方法。此 API 调用返回可以保存在磁盘上的输出流。

使用 C# RESTful 服务从在线 PPT 中去除水印的代码

// Include necessary namespaces for working with Aspose.Slides API
using Aspose.Slides.Cloud.Sdk;
using Aspose.Slides.Cloud.Sdk.Model;
using System;
using System.IO;
namespace WatermarkRemovalExample
{
class Program
{
static void Main(string[] args)
{
// Configure the API client using your credentials
var apiClient = new SlidesApi("YourApiKeyHere", "YourApiSecretHere");
// Define file paths for input and output presentations
string sourcePresentation = "PresentationWithWatermark.pptx";
string updatedPresentation = "CleanedPresentation.pptx";
// Open the source presentation as a stream
using (var sourceStream = File.OpenRead(sourcePresentation))
{
// Remove watermark elements from the presentation
var cleanedStream = apiClient.DeleteWatermarkOnline(sourceStream);
// Save the cleaned presentation to a new file
using (var outputStream = File.Create(updatedPresentation))
{
cleanedStream.CopyTo(outputStream);
}
}
// Notify the user about the successful process
Console.WriteLine($"Watermark removed successfully. Updated file saved as '{updatedPresentation}'.");
}
}
}

此代码演示如何使用基于 C# .NET 的 API 从 PowerPoint 幻灯片中删除水印。它从演示文稿中的所有幻灯片中删除水印。如果源演示文稿受密码保护,请使用 API 调用中的密码属性打开文件以删除水印。

本文教会了我们如何使用 C# REST API 从 PPTX 中删除水印。要在演示文稿中插入水印,请参阅有关 使用 C# REST API 为 PPT 添加水印 的文章。

 简体中文