Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial


Watermarks are text or pictures that appear behind document content and often identify the document status, for example by marking it as Draft.

Watermark Overview

The class representing a watermark is Watermark and exposes the following properties:

  • WatermarkType: The type of the watermark, described with the WatermarkType enumeration.

    • Image: Watermark containing an image.
    • Text: Watermark containing text.
  • ImageSettings: Determines the settings of the watermark if it is of type Image. Derives from WatermarkSettingsBase and exposes a property of type ImageSource specifying the source of the image.

  • TextSettings: Determines the settings of the watermark if it is of type Text. Derives from WatermarkSettingsBase and exposes additional properties Text, FontFamily and Color specifying the appearance of the text.

WatermarkSettingsBase is the base class for text and image watermark settings and defines the appearance of the watermark on a page. It exposes the following properties:

  • Width: The width of the watermark.
  • Height: The height of the watermark.
  • Angle: The angle of the watermark towards the horizontal direction.

Create a Watermark

Creating a watermark through the constructor of the class requires to pass as a parameter an object of type TextWatermarkSettings or ImageWatermarkSettings, depending on the type of watermark you want to create.

Example 1 demonstrates the creation of a text watermark.

Example 1: Create text watermark

TextWatermarkSettings settings = new TextWatermarkSettings() 
    Angle = 12, 
    Width = 200, 
    Height = 300, 
    Opacity = 0.4, 
    FontFamily = new FontFamily("Verdana"), 
    ForegroundColor = Colors.Red, 
    Text = "DRAFT" 
Watermark textWatermark = new Watermark(settings); 

Creating image watermark is very similar to creating a text one. Example 2 shows how to create an image watermark.

Example 2: Create image watermark

Watermark imageWatermark = new Watermark(new ImageWatermarkSettings() 
    Angle = 45, 
    Width = 50, 
    Height = 75, 
    ImageSource = new Telerik.Windows.Documents.Media.ImageSource(imageStream, "png") 

Set Watermark

Watermarks are preserved in the header of the section to which the watermark is applied. More information on Header elements and how you can use them is available in the Headers and Footers article.

Example 3 demonstrates how you can add the watermark created in Example 1 to a RadFlowDocument by creating a Header for its first Section.

Example 3: Add watermark to header

Header header = document.Sections.First().Headers.Add(HeaderFooterType.Default); 

By default, if header is omitted for a Section other than the first one, it is inherited from the previous Section. The watermark set in Example 3 will be implicitly inherited by all sections following the first one since watermarks are preserved in the header.

There is another way to set a watermark in a document - through the RadFlowDocumentEditor class. RadFlowDocumentEditor exposes two overloads of the SetWatermark() method that provide a simplified way to set a watermark.

Example 4 demonstrates how to set the watermark created in Example 2 through RadFlowDocumentEditor to the first page of a section. The method will create the Header element for you, and you only need to specify its type.

Example 4: Set watermark with RadFlowDocumentEditor

Section section = editor.Document.Sections.AddSection(); 
editor.SetWatermark(imageWatermark, section, HeaderFooterType.First); 

See Also

In this article