Skip to main content
All docs
V24.1

WatermarkFormat.SetText(String) Method

Replaces watermark text.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

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.OpenXml);

The following image demonstrates the result:

Text Watermarks

See Also