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

WatermarkFormat.SetImage(Image) Method

Replaces the watermark image.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

#Declaration

[Browsable(false)]
void SetImage(
    Image image
)

#Parameters

Name Type Description
image Image

A new watermark image.

#Remarks

The following code adds an image watermark to the entire document and then changes the image for the watermark located in the primary header of the first section:

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

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

// Add an image watermark to the document.
document.WatermarkManager.SetImage(Image.FromFile(@"Images\DevExpressLogo.png"));

// 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 the watermark image.
if (watermark != null && watermark.WatermarkFormat.Type == WatermarkType.Image)
{
    watermark.WatermarkFormat.SetImage(Image.FromFile(@"Images\DevAVLogo.png"));
}
firstSection.EndUpdateHeader(headerContent);
document.SaveDocument(@"Documents\WatermarksUpd.docx", DocumentFormat.OpenXml);
See Also