Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 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

WatermarkManager.SetImage(Section, HeaderFooterType, DocumentImageSource, ImageWatermarkOptions) Method

Adds an image watermark to a header of the specified section.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

#Declaration

void SetImage(
    Section section,
    HeaderFooterType type,
    DocumentImageSource imageSource,
    ImageWatermarkOptions options
)

#Parameters

Name Type Description
section Section

The target section.

type HeaderFooterType

The type of the section’s header in which to insert the watermark.

imageSource DocumentImageSource

A watermark image.

options ImageWatermarkOptions

An object that contains image watermark options.

#Remarks

If you need to add a watermark to a header of a specific section, ensure that the Section.IsHeaderLinkedToPrevious and Section.IsHeaderLinkedToNext methods return false for this header. Otherwise, the header has the same content as the header of the previous or next section, respectively.

If a section defined by the section parameter does not have a header of the specified type, the SetImage method creates this header. Consider the following when you use this method to create a header and insert a watermark:

The code sample below adds different watermarks to the document sections. The document contains two sections: the first section occupies the first page, and the second section occupies the second page. All sections have no headers. The WatermarkManager.SetImage method creates the first page header for the first section and adds an image watermark to this header. The WatermarkManager.SetText method creates a primary header (the same header for all pages) for the second section and inserts a text watermark into this header.

Image and Text Watermarks

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System.Drawing;
// ...

document.LoadDocument(@"Documents\Watermarks.docx");

var firstSection = document.Sections[0];
var secondSection = document.Sections[1];

// Define image watermark options.
var imageWatermarkOptions = new ImageWatermarkOptions
{ Washout = false };

// Add an image watermark to the first page header. 
firstSection.DifferentFirstPage = true;
document.WatermarkManager.SetImage(firstSection, HeaderFooterType.First, 
    DocumentImageSource.FromFile(@"Images\DevExpressLogo.png"), imageWatermarkOptions);

// Add a text watermark to the second section's header.
document.WatermarkManager.SetText(secondSection, HeaderFooterType.Primary, "DRAFT");
document.SaveDocument(@"Documents\WatermarksUpd.docx", DocumentFormat.OpenXml);
See Also