Posted By

nausherwan on 05/21/14


Tagged

cloud presentation Aspose asposeslides


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

a-mewang


C# Code Sample to Replace All Text Instances in a Presentation using Cloud API


 / Published in: C#
 

URL: http://www.aspose.com/docs/display/slidescloud/Replace+All+Text+Instances+in+a+Presentation

This example allows you to replace all instances of a text in a Presentation using Aspose.Slides for Cloud API in your applications. You can use our REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.

  1. string FileName = "presentation.pptx";
  2. string oldText = "slide";
  3. string newText = "Aspose.Slide";
  4.  
  5. //build URI to replace text
  6. string strURI = "http://api.aspose.com/v1.1//slides/" + FileName + "/replaceText?oldValue=" +
  7. oldText + "&newValue=" + newText + "&ignoreCase=true";
  8. string signedURI = Utils.Sign(strURI);
  9.  
  10. Stream responseStream = Utils.ProcessCommand(signedURI, "POST");
  11. StreamReader reader = new StreamReader(responseStream);
  12. string strJSON = reader.ReadToEnd();
  13.  
  14. //Parse the json string to JObject
  15. JObject parsedJSON = JObject.Parse(strJSON);
  16.  
  17. //Deserializes the JSON to a object.
  18. BaseResponse baseResponse = JsonConvert.DeserializeObject<BaseResponse>(parsedJSON.ToString());
  19.  
  20. if (baseResponse.Code == "200" && baseResponse.Status == "OK")
  21. Console.WriteLine("Text Replaced successfully");
  22. else
  23. Console.WriteLine("Not able to replace the text");
  24.  
  25. //Here is the BaseResponse class
  26. public class BaseResponse
  27. {
  28. public BaseResponse() { }
  29. public string Code { get; set; }
  30. public string Status { get; set; }
  31. }

Report this snippet  

You need to login to post a comment.