DocumentPartAddWatermark Method
Adds a watermark to this DocumentPart.

Namespace: GroupDocs.Watermark
Assembly: GroupDocs.Watermark (in GroupDocs.Watermark.dll) Version: 19.5
Syntax
public virtual void AddWatermark(
	Watermark watermark
)

Parameters

watermark
Type: GroupDocs.WatermarkWatermark
The watermark to add to the document.
Examples
Add image and text watermark to a document of any supported type.
C#
using (Document document = Document.Load(@"D:\input.pdf"))
{
    TextWatermark textWatermark = new TextWatermark("DRAFT", new Font("Arial", 19));
    textWatermark.HorizontalAlignment = HorizontalAlignment.Center;
    textWatermark.VerticalAlignment = VerticalAlignment.Top;
    textWatermark.ConsiderParentMargins = true;
    textWatermark.ForegroundColor = Color.Red;
    textWatermark.IsBackground = true;
    textWatermark.Opacity = 0.5;
    document.AddWatermark(textWatermark);
    using (ImageWatermark imageWatermark = new ImageWatermark(@"D:\draft.png"))
    {
        imageWatermark.HorizontalAlignment = HorizontalAlignment.Center;
        imageWatermark.VerticalAlignment = VerticalAlignment.Bottom;
        imageWatermark.ConsiderParentMargins = true;
        imageWatermark.IsBackground = true;
        imageWatermark.Opacity = 0.5;
        document.AddWatermark(imageWatermark);
    }
    document.Save(@"D:\output.pdf");
}
See Also