Skip to content

Instantly share code, notes, and snippets.

@groupdocs-com-kb
Last active February 14, 2023 11:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save groupdocs-com-kb/0f655e9f5330f0a3ed4bc4fe12270fc1 to your computer and use it in GitHub Desktop.
How to Add Watermark in Word using C#. For more information, please follow link: https://kb.groupdocs.com/annotation/net/how-to-add-watermark-in-word-using-charp/
using System;
using GroupDocs.Annotation;
using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;
namespace AddWatermarkinWordUsingCSharp
{
internal class Program
{
static void Main(string[] args)
{
// Set License to avoid the limitations of Annotation library
License lic = new License();
lic.SetLicense(@"Conholdate.Annotator.lic");
//Instantiate Annotator object and pass input Word document
using (Annotator annotator = new Annotator("input.docx"))
{
//Instantiate WatermarkAnnotation object and set it's properties
WatermarkAnnotation watermark = new WatermarkAnnotation
{
Angle = 75,
Box = new Rectangle(200, 200, 100, 50),
CreatedOn = DateTime.Now,
Text = "Watermark",
FontColor = 65535,
FontSize = 12,
Message = "This is watermark annotation",
Opacity = 0.7,
AutoScale = true,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
//Add Watermark in Word document
annotator.Add(watermark);
//Save the final output DOCX
annotator.Save("result.docx");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment