Add Watermark to PPT with C# REST API

This article guides how to add watermark to PPT with C# REST API. You will learn the insertion of PowerPoint watermark with C# Low Code API using a .NET-based Cloud SDK. Various options will be discussed to customize the watermark in the presentation.

Prerequisite

Steps to Insert Watermark in PPT with C# REST API

  1. Initialize the SlidesApi object with a client ID and secret to add a watermark
  2. Create a Shape object by setting the Text and TextFrameFormat properties
  3. Read the input presentation file into a stream
  4. Call the CreateWatermarkOnline() method by providing the input file stream and shape
  5. Save the returned stream into a local file on the disk

These steps describe how to insert a watermark in PowerPoint with C# RESTful Service. Create a shape for defining the watermark by setting the text and rotation angle. Call the CreateWatermarkOnline() method to add a watermark by providing the input presentation and the Shape object containing the watermark parameters.

Code to Create a Watermark in PowerPoint with C# REST Interface

using Aspose.Slides.Cloud.Sdk;// Importing the SDK for managing presentations
using Aspose.Slides.Cloud.Sdk.Model; // Importing models used for creating and manipulating presentation components
using System;
using System.Collections.Generic;
using System.IO;
namespace AsposeTestCodes
{
class ShapeAdder
{
static void Main(string[] args) // Main entry point of the program
{
// Initialize the API client with API key and secret
SlidesApi presentationApi = new SlidesApi("Client ID", "Secret");
var inputFilePath = "Sample.pptx";
var outputFilePath = "output.pptx";
var shape = new Shape
{
Text = "Powered by Aspose.",
TextFrameFormat = new TextFrameFormat
{
RotationAngle = 45
}
};
var inputStream = File.OpenRead(inputFilePath);
var outputStream = presentationApi.CreateWatermarkOnline(inputStream, shape);
var fileStream = File.OpenWrite(outputFilePath);
outputStream.CopyTo(fileStream);
}
}
}

This code demonstrates how to put a watermark in PowerPoint with C# .NET-based API. The Shape object contains a lot of characteristics that you can set to customize the watermark. Options are also available to add an image watermark in the presentation.

This article has guided us to add a watermark. If you want to generate a PowerPoint from an HTML file, refer to the article Convert HTML to PowerPoint with C# REST API.

 English