Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    WatermarkFormat.SetText(String) Method

    Replaces watermark text.

    Namespace: DevExpress.XtraRichEdit.API.Native

    Assembly: DevExpress.RichEdit.v25.1.Core.dll

    NuGet Package: DevExpress.RichEdit.Core

    #Declaration

    void SetText(
        string text
    )

    #Parameters

    Name Type Description
    text String

    New watermark text.

    #Remarks

    The following code adds a text watermark to the entire document and then changes watermark text in the primary header of the first section:

    using DevExpress.XtraRichEdit;
    using DevExpress.XtraRichEdit.API.Native;
    using System.Linq;
    // ...
    
    document.LoadDocument(@"Documents\Watermarks.docx");
    
    // Add a text watermark to the document.
    document.WatermarkManager.SetText("DO NOT COPY");
    
    // Access the first document section.
    Section firstSection = document.Sections[0];
    
    // Obtain the section's primary header.
    SubDocument headerContent = firstSection.BeginUpdateHeader();
    // Retrieve the header's watermark.
    var watermark = headerContent.Shapes.SingleOrDefault(x => x.Type == ShapeType.Watermark);
    // Change watermark text.
    if (watermark != null && watermark.WatermarkFormat.Type == WatermarkType.Text)
    {
        watermark.WatermarkFormat.SetText("CONFIDENTIAL");
    }
    firstSection.EndUpdateHeader(headerContent);
    document.SaveDocument(@"Documents\WatermarksUpd.docx", DocumentFormat.Docx);
    

    The following image demonstrates the result:

    Text Watermarks

    See Also