officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-watermarkformat.md
Returns options for the text watermark.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
TextWatermarkOptions TextOptions { get; }
ReadOnly Property TextOptions As TextWatermarkOptions
| Type | Description |
|---|---|
| TextWatermarkOptions |
An object that contains text watermark options.
|
The TextOptions property allows you to access and modify text settings (font attributes, text color, and layout) for a watermark.
The example below demonstrates how to change text watermark options. The code iterates through all document sections and updates settings for text watermarks in primary headers. The WatermarkFormat.Type property is used to check the watermark type.
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System.Drawing;
using System.Linq;
// ...
document.LoadDocument(@"Documents\Watermarks.docx");
// Add a text watermark to the document.
document.WatermarkManager.SetText("CONFIDENTIAL");
foreach (Section section in document.Sections)
{
// Obtain the section's primary header.
SubDocument headerContent = section.BeginUpdateHeader();
// Retrieve the header's watermark.
Shape watermark = headerContent.Shapes.SingleOrDefault(x => x.Type == ShapeType.Watermark);
// Change text watermark options.
if (watermark != null && watermark.WatermarkFormat.Type == WatermarkType.Text)
{
watermark.WatermarkFormat.TextOptions.Color = Color.SlateGray;
watermark.WatermarkFormat.TextOptions.FontFamily = "Segoe UI";
watermark.WatermarkFormat.TextOptions.Layout = WatermarkLayout.Horizontal;
watermark.WatermarkFormat.TextOptions.Semitransparent = true;
}
section.EndUpdateHeader(headerContent);
}
document.SaveDocument(@"Documents\WatermarksUpd.docx", DocumentFormat.Docx);
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports System.Drawing
Imports System.Linq
' ...
document.LoadDocument("Documents\Watermarks.docx")
' Add a text watermark to the document.
document.WatermarkManager.SetText("CONFIDENTIAL")
For Each section As Section In document.Sections
' Obtain the section's primary header.
Dim headerContent As SubDocument = section.BeginUpdateHeader()
' Retrieve the header's watermark.
Dim watermark As Shape = headerContent.Shapes.SingleOrDefault(Function(x) x.Type = ShapeType.Watermark)
' Change text watermark options.
If watermark IsNot Nothing AndAlso watermark.WatermarkFormat.Type = WatermarkType.Text Then
watermark.WatermarkFormat.TextOptions.Color = Color.SlateGray
watermark.WatermarkFormat.TextOptions.FontFamily = "Segoe UI"
watermark.WatermarkFormat.TextOptions.Layout = WatermarkLayout.Horizontal
watermark.WatermarkFormat.TextOptions.Semitransparent = True
End If
section.EndUpdateHeader(headerContent)
Next section
document.SaveDocument("Documents\WatermarksUpd.docx", DocumentFormat.Docx)
The following image demonstrates the result:
See Also