menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class TextWatermark - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Class TextWatermark

    Represents the text that appears behind the document.

    Inheritance
    System.Object
    OwnerHolder
    XDLSSerializableBase
    Entity
    WidgetBase
    ParagraphItem
    Watermark
    TextWatermark
    Implements
    IXDLSSerializable
    IParagraphItem
    IEntity
    IOfficeRun
    Inherited Members
    Entity.Clone()
    Entity.IsComposite
    Entity.NextSibling
    Entity.Owner
    Entity.PreviousSibling
    OwnerHolder.Document
    OwnerHolder.m_doc
    ParagraphItem.ApplyStyle(String)
    ParagraphItem.CloneImpl()
    ParagraphItem.CloneRun()
    ParagraphItem.Dispose()
    ParagraphItem.IsDeleteRevision
    ParagraphItem.IsInsertRevision
    ParagraphItem.m_charFormat
    ParagraphItem.OwnerMathRunElement
    ParagraphItem.OwnerParagraph
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Watermark.CreateLayoutInfo()
    Watermark.EntityType
    Watermark.Type
    XDLSSerializableBase.InitXDLSHolder()
    XDLSSerializableBase.IXDLSSerializable.ReadXmlAttributes(IXDLSAttributeReader)
    XDLSSerializableBase.IXDLSSerializable.ReadXmlContent(IXDLSContentReader)
    XDLSSerializableBase.IXDLSSerializable.RestoreReference(String, Int32)
    XDLSSerializableBase.IXDLSSerializable.WriteXmlAttributes(IXDLSAttributeWriter)
    XDLSSerializableBase.IXDLSSerializable.WriteXmlContent(IXDLSContentWriter)
    XDLSSerializableBase.IXDLSSerializable.XDLSHolder
    XDLSSerializableBase.ReadXmlContent(IXDLSContentReader)
    XDLSSerializableBase.RestoreReference(String, Int32)
    XDLSSerializableBase.WriteXmlContent(IXDLSContentWriter)
    XDLSSerializableBase.XDLSHolder
    Namespace: Syncfusion.DocIO.DLS
    Assembly: Syncfusion.DocIO.Base.dll
    Syntax
    public class TextWatermark : Watermark, IXDLSSerializable, IWidget, IParagraphItem, IEntity, IOfficeRun
    Examples

    The following code snippet illustrates how to add a text watermark to the Word document.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Create a new Word document
        WordDocument document = new WordDocument();
        //Add a section and a paragraph in the document
        document.EnsureMinimal();
        IWParagraph paragraph = document.LastParagraph;
        paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
        //Create a new text watermark
        TextWatermark textWatermark = new TextWatermark();
        //Set the created watermark to document
        document.Watermark = textWatermark;
        //Set the text watermark font size
        textWatermark.Size = 72;
        //Set the text watermark layout to Horizontal
        textWatermark.Layout = WatermarkLayout.Horizontal;
        textWatermark.Semitransparent = false;
        //Set the text watermark text color
        textWatermark.Color = Color.Black;
        //Set the text to text watermark text
        textWatermark.Text = "TextWatermark";
        document.Save("TextWatermark.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Create a new Word document
        Dim document As New WordDocument()
        'Add a section and a paragraph in the document
        document.EnsureMinimal()
        Dim paragraph As IWParagraph = document.LastParagraph
        paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
        'Create a new text watermark
        Dim textWatermark As New TextWatermark()
        'Set the text watermark to document
        document.Watermark = textWatermark
        'Set the text watermark font size
        textWatermark.Size = 72
        'Set the text watermark layout to Horizontal
        textWatermark.Layout = WatermarkLayout.Horizontal
        textWatermark.Semitransparent = False
        'Set the text watermark text color
        textWatermark.Color = Color.Black
        'Set the text to the text watermark
        textWatermark.Text = "TextWatermark"
        document.Save("TextWatermark.docx", FormatType.Docx)
        document.Close()
    End Sub

    Constructors

    TextWatermark()

    Initializes a new instance of the TextWatermark class.

    Declaration
    public TextWatermark()

    TextWatermark(String)

    Initializes a new instance of the TextWatermark class with watermark text.

    Declaration
    public TextWatermark(string text)
    Parameters
    Type Name Description
    System.String text

    A String that appears behind the document

    Examples

    The following code snippet illustrates how to add a text watermark to the Word document.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Load an existing Word document into DocIO instance
        WordDocument document = new WordDocument("Template,docx");
        //Create a new text watermark
        TextWatermark textWatermark = new TextWatermark("Demo Text");
        //Set the created watermark to document
        document.Watermark = textWatermark;
        document.Save("TextWatermark.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Load an existing Word document into DocIO instance
        Dim document As New WordDocument("Template,docx")
        'Create a new text watermark
        Dim textWatermark As New TextWatermark("Demo Text")
        'Set the created watermark to document
        document.Watermark = textWatermark
        document.Save("TextWatermark.docx", FormatType.Docx)
        document.Close()
    End Sub

    TextWatermark(String, String, Int32, WatermarkLayout)

    Initializes a new instance of the TextWatermark class with the specified watermark text, font name, font size and layout options.

    Declaration
    public TextWatermark(string text, string fontName, int fontSize, WatermarkLayout layout)
    Parameters
    Type Name Description
    System.String text

    A String that represents Text which appears behind the document

    System.String fontName

    A String that represents the font name for the text

    System.Int32 fontSize

    A float value that represents the visual appearance size for the text

    WatermarkLayout layout

    A WatermarkLayout represents the appearance position of the watermark text in this WordDocument

    Examples

    The following code snippet illustrates how to add a text watermark to the Word document.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Load an existing Word document into DocIO instance
        WordDocument document = new WordDocument("Template,docx");
        //Create a new text watermark
        TextWatermark textWatermark = new TextWatermark("Demo Text", "Arial", 48, WatermarkLayout.Diagonal);
        //Set the created watermark to document
        document.Watermark = textWatermark;
        document.Save("TextWatermark.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Load an existing Word document into DocIO instance
        Dim document As New WordDocument("Template,docx")
        'Create a new text watermark
        Dim textWatermark As New TextWatermark("Demo Text", "Arial", 48, WatermarkLayout.Diagonal)
        'Set the created watermark to document
        document.Watermark = textWatermark
        document.Save("TextWatermark.docx", FormatType.Docx)
        document.Close()
    End Sub

    Properties

    Color

    Gets or sets watermark text display color.

    Declaration
    public Color Color { get; set; }
    Property Value
    Type Description
    System.Drawing.Color

    A Color value represents the visual appearance color for the Text

    FontName

    Gets or sets watermark text's font name.

    Declaration
    public string FontName { get; set; }
    Property Value
    Type Description
    System.String

    A String that represents the font name for the Text

    Remarks

    Setting new value to this FontName will not auto update the width and height of the TextWatermark. Have to specify the Syncfusion.DocIO.DLS.TextWatermark.Width and Syncfusion.DocIO.DLS.TextWatermark.Height explicitly in ASP.NET Core and Xamarin platforms

    Item[Int32]

    Gets or sets the key in property collection.

    Declaration
    protected object this[int key] { get; set; }
    Parameters
    Type Name Description
    System.Int32 key

    The integer that specifies the key.

    Property Value
    Type Description
    System.Object

    An object that specifies the key.

    Layout

    Gets or sets layout for watermark text.

    Declaration
    public WatermarkLayout Layout { get; set; }
    Property Value
    Type Description
    WatermarkLayout

    A WatermarkLayout represents the appearance position of the watermark text in this WordDocument.

    Semitransparent

    Gets or sets semitransparent property for Text watermark. The default is false.

    Declaration
    public bool Semitransparent { get; set; }
    Property Value
    Type Description
    System.Boolean

    True if the watermark text appear as semitransparent; otherwise, false

    Size

    Gets or sets watermark text's size.

    Declaration
    public float Size { get; set; }
    Property Value
    Type Description
    System.Single

    A float value that represents the visual appearance size for the Text

    Remarks

    Setting new value to this Size will not auto update the width and height of the TextWatermark. Have to specify the Syncfusion.DocIO.DLS.TextWatermark.Width and Syncfusion.DocIO.DLS.TextWatermark.Height explicitly in ASP.NET Core and Xamarin platforms

    Text

    Gets or sets watermark text.

    Declaration
    public string Text { get; set; }
    Property Value
    Type Description
    System.String

    A String that appear behind the document.

    Methods

    ReadXmlAttributes(IXDLSAttributeReader)

    Reads object data from xml attributes.

    Declaration
    protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
    Parameters
    Type Name Description
    IXDLSAttributeReader reader

    The IXDLSAttributeReader object.

    Overrides
    Watermark.ReadXmlAttributes(IXDLSAttributeReader)

    WriteXmlAttributes(IXDLSAttributeWriter)

    Writes object data as xml attributes.

    Declaration
    protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
    Parameters
    Type Name Description
    IXDLSAttributeWriter writer

    The IXDLSAttributeWriter object.

    Overrides
    Watermark.WriteXmlAttributes(IXDLSAttributeWriter)

    Implements

    IXDLSSerializable
    IParagraphItem
    IEntity
    IOfficeRun

    See Also

    Watermark
    PictureWatermark
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved