Watermarks are usually used to show ownership or classification of a document. In this article, we will learn to work with watermark in word documents using Aspose.Words for .NET API. Let us cover the following use cases related to watermark.
- Add Text Watermark in Word Document with C#
- Add Image Watermark in Word Document with C#
- Remove Watermark from Word Document with C#
Add Text Watermark in Word Document with C#
You can add or insert text watermark in a word document, be it a DOC or DOCX file. Simply follow the steps below for adding text watermark:
- Load input DOC/DOCX file
- Set different TextWatermarkOptions including Font and Layout
- Set text of the watermark
- Save the output word file
Following code snippet shows how to add watermark in word document (DOC/DOCX) using C#:
The screenshot below is a sample output created by above C# code snippet:
Add Image Watermark in Word Document with C#
You can also add an image as a watermark in a word document. The image can be added in addition to the text, as we have learned in the previous example. You can follow below steps to add image watermark in a word document:
- Load input word file
- Initialize ImageWatermarkOptions object
- Set image as watermark in the word document
- Save the output file
Following code snippet is based on these steps which show how to add image watermark in word documents using C#:
We have used Aspose logo image as sample image so you can observe the output in Print Preview of Microsoft Word application where an image is set as a watermark of the document. Following screenshot depicts the output word file:
Remove Watermark in Word Document using C#
You can easily remove or delete a watermark from word document using C#. Let us follow the steps below for removing a watermark from the word document.
- Load input word file
- Specify the type of watermark to remove
- Remove watermark
- Save the output word file
Following code snippet shows how to remove a watermark from word document with C#:
Conclusion
We have learned how to add or insert text watermark in word documents. Moreover, we have also explored how to add image watermark in word documents. You can use these features separately or maybe in combination as well, i.e Adding text and image watermark in word document at the same time. Furthermore, your .NET application can be efficient enough to remove or watermarks from word documents. We have created this article as a simple guide to work with watermarks in word. In case of any query or concerns, please contact us via Free Support Forum.