Watermark

Watermark class

Represents class to work with document watermark.

To learn more, visit the Working with Watermark documentation article.

public sealed class Watermark

Properties

NameDescription
Type { get; }Gets the watermark type.

Methods

NameDescription
Remove()Removes the watermark.
SetImage(Image)Adds Image watermark into the document.
SetImage(Image, ImageWatermarkOptions)Adds Image watermark into the document.
SetImage(string, ImageWatermarkOptions)Adds Image watermark into the document.
SetText(string)Adds Text watermark into the document.
SetText(string, TextWatermarkOptions)Adds Text watermark into the document.

Examples

Shows how to create a text watermark.

Document doc = new Document();

// Add a plain text watermark.
doc.Watermark.SetText("Aspose Watermark");

// If we wish to edit the text formatting using it as a watermark,
// we can do so by passing a TextWatermarkOptions object when creating the watermark.
TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
textWatermarkOptions.FontFamily = "Arial";
textWatermarkOptions.FontSize = 36;
textWatermarkOptions.Color = Color.Black;
textWatermarkOptions.Layout = WatermarkLayout.Diagonal;
textWatermarkOptions.IsSemitrasparent = false;

doc.Watermark.SetText("Aspose Watermark", textWatermarkOptions);

doc.Save(ArtifactsDir + "Document.TextWatermark.docx");

// We can remove a watermark from a document like this.
if (doc.Watermark.Type == WatermarkType.Text)
    doc.Watermark.Remove();

See Also