Skip to main content
A newer version of this page is available. .
All docs
V21.1
.NET Framework 4.5.2+

WatermarkManager Interface

Manages document watermarks.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

public interface WatermarkManager

Remarks

WatermarkManager allows you to add and remove watermarks without access to the watermark itself. You can use text or an image as a watermark.

A watermark is located in the section header. If the document does not contain headers, you cannot add a watermark. Refer to the following article for an example on how to create headers: Headers and Footers

If the document has multiple sections, the WatermarkManager adds the same watermark to each section and to each available header type (first, primary, odd or even).

The WatermarkManager.Type property indicates whether the document has watermarks. The property returns WatermarkType.None if the document does not contain watermarks.

Example

The code sample below adds a text watermark:

image

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument("DocumentProtection.docx");

    // Check whether the document sections have headers:
    foreach (Section section in wordProcessor.Document.Sections)
    {
        if (!section.HasHeader(HeaderFooterType.Primary))
        {
            // If not, create an empty header
            SubDocument header = section.BeginUpdateHeader();
            section.EndUpdateHeader(header);
        }
    }

    TextWatermarkOptions textWatermarkOptions = new TextWatermarkOptions();
    textWatermarkOptions.Color = System.Drawing.Color.LightGray;
    textWatermarkOptions.FontFamily = "Calibri";
    textWatermarkOptions.Layout = WatermarkLayout.Diagonal;
    textWatermarkOptions.Semitransparent = true;

    wordProcessor.Document.WatermarkManager.SetText("CONFIDENTIAL", textWatermarkOptions);
    wordProcessor.SaveDocument("DocumentProtection_new.docx", DocumentFormat.OpenXml);
}
See Also