Add Watermark Text to a Word Document in the Cloud

Posted by Zarfishan under ASP.NET category on | Points: 40 | Views : 1272
This technical tip allows developers to add watermark text to a Word document using Saaspose.Words REST API in your .NET applications. Some important steps for performing this task are to build URI to add watermark text and then serialize the JSON request content. After that, parse the json string to JObject. Developers can use the WatermarkText class and BaseResponse class for adding Watermark text.

Sample Code for Adding Watermark Text to a Word Document

//build URI to add watermark text
stringstrURI = "";
stringsignedURI = Sign(strURI);
//serialize the JSON request content
WatermarkText watermark = new WatermarkText();
watermark.Text = "Watermark Text Here";
watermark.RotationAngle = 45.0;
stringstrJSON = JsonConvert.SerializeObject(watermark);
Stream responseStream = ProcessCommand(signedURI, "POST", strJSON);
StreamReader reader = new StreamReader(responseStream);
stringstrResponse = reader.ReadToEnd();
//Parse the json string to JObject
JObjectpJSON = JObject.Parse(strResponse);
BaseResponsebaseResponse = JsonConvert.DeserializeObject<BaseResponse>(pJSON.ToString());
if (baseResponse.Code == "200" &&baseResponse.Status == "OK")
Console.WriteLine("Watermark text has been added successfully");

//Here is the WatermarkText class
public class WatermarkText
public string Text { get; set; }
public double RotationAngle { get; set; }

//Here is the BaseResponse class
public class BaseResponse
publicBaseResponse() { }
public string Code { get; set; }
public string Status { get; set; }

Comments or Responses

Login to post response