This article demonstrates how to replace text within a PowerPoint document or a particular PowerPoint slide using the TextApi interface provided by Spire.Cloud.PowerPoint.
Replace text within a PowerPoint document
using Spire.Cloud.Powerpoint.Sdk.Api;
using Spire.Cloud.Powerpoint.Sdk.Client;
namespace ReplaceText
{
class Program
{
static string appId = "APP ID";
static string appKey = "APP Key";
static string baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration instance based on your AppID and AppKey
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a TextApi instance
static TextApi textApi = new TextApi(configuration);
static void Main(string[] args)
{
//Specify the input document
string name = "template.pptx";
//Specify the text that you want to replace
string oldValue = "Spire.Presentation";
//Specify the desired text
string newValue = "New String";
//Specify ignoreCase
bool ignoreCase = true;
//Specify the password used to open the document, and it's "null" if nothing
string password = null;
//Specify the folder storing the input document, and it's "null" if nothing
string folder = "input";
//Use the 2G storage provided by E-iceblue, and it's "null" by default
string storage = null;
//Call ReplacePresentationText method to replace text within the document
textApi.ReplacePresentationText(name, oldValue, newValue, ignoreCase, password, folder, storage);
}
}
}
Replace text within a particular PowerPoint slide
using Spire.Cloud.Powerpoint.Sdk.Api;
using Spire.Cloud.Powerpoint.Sdk.Client;
namespace ReplaceText
{
class Program
{
static string appId = "APP ID";
static string appKey = "APP Key";
static string baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration instance based on your AppID and AppKey
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a TextApi instance
static TextApi textApi = new TextApi(configuration);
static void Main(string[] args)
{
//Specify the input document
string name = "template.pptx";
//Specify the slide index
int slideIndex = 0;
//Specify the text that you want to replace
string oldValue = "Spire.Presentation";
//Specify the desired text
string newValue = "New String";
//Specify ignoreCase
bool ignoreCase = true;
//Specify the password used to open the document, and it's "null" if nothing
string password = null;
//Specify the folder storing the input document, and it's "null" if nothing
string folder = "input";
//Use the 2G storage provided by E-iceblue, and it's "null" by default
string storage = null;
//Call ReplaceSlideText method to replace text within the slide
textApi.ReplaceSlideText(name, slideIndex, oldValue, newValue, ignoreCase, password, folder, storage);
}
}
}