Over a million developers have joined DZone.

Watermark Text Addition to Word Documents in .NET Applications

DZone's Guide to

Watermark Text Addition to Word Documents in .NET Applications

· ·
Free Resource
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.
//build URI to add watermark text
            string strURI = "http://api.saaspose.com/v1.0/words/input.docx/insertWatermarkText";
            string signedURI = Sign(strURI);
            //serialize the JSON request content
            WatermarkText watermark = new WatermarkText();
            watermark.Text = "Watermark Text Here";
            watermark.RotationAngle = 45.0;
            string strJSON = JsonConvert.SerializeObject(watermark);
            Stream responseStream = ProcessCommand(signedURI, "POST", strJSON);
            StreamReader reader = new StreamReader(responseStream);
            string strResponse = reader.ReadToEnd();
            //Parse the json string to JObject
            JObject pJSON = JObject.Parse(strResponse);
            BaseResponse baseResponse = JsonConvert.DeserializeObject
            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
        	public BaseResponse() { }
	        public string Code { get; set; }
        	public string Status { get; set; }

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}