officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-watermarkformat-d147ad4e.md
Returns options for the image watermark.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
ImageWatermarkOptions ImageOptions { get; }
ReadOnly Property ImageOptions As ImageWatermarkOptions
| Type | Description |
|---|---|
| ImageWatermarkOptions |
An object that contains image watermark options.
|
The ImageOptions property allows you to access and modify image settings for a watermark. You can change the image scale percentage (Scale) and apply or remove the washout effect (Washout).
The example below demonstrates how to change image watermark options. The code iterates through all document sections and updates settings for image 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 an image watermark to the document.
document.WatermarkManager.SetImage(Image.FromFile(@"Images\DevExpressLogo.png"));
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 watermark image options.
if (watermark != null && watermark.WatermarkFormat.Type == WatermarkType.Image)
{
watermark.WatermarkFormat.ImageOptions.Washout = false;
watermark.WatermarkFormat.ImageOptions.Scale = 3;
watermark.RotationAngle = -45;
}
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 an image watermark to the document.
document.WatermarkManager.SetImage(Image.FromFile("Images\DevExpressLogo.png"))
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 watermark image options.
If watermark IsNot Nothing AndAlso watermark.WatermarkFormat.Type = WatermarkType.Image Then
watermark.WatermarkFormat.ImageOptions.Washout = False
watermark.WatermarkFormat.ImageOptions.Scale = 3
watermark.RotationAngle = -45
End If
section.EndUpdateHeader(headerContent)
Next section
document.SaveDocument("Documents\WatermarksUpd.docx", DocumentFormat.Docx)
The following image demonstrates the result:
See Also