Skip to main content
A newer version of this page is available. .

Watermark Class

A document’s watermark.

Namespace: DevExpress.XtraPrinting.Drawing

Assembly: DevExpress.Printing.v22.2.Core.dll

NuGet Packages: DevExpress.Printing.Core, DevExpress.Win.Dashboard.Design

Declaration

public class Watermark :
    PageWatermark

The following members return Watermark objects:

Library Related API Members
Cross-Platform Class Library IReport.Watermark
PrintingSystemBase.Watermark
WinForms Controls PrintingSystem.Watermark
WPF Controls IDocumentViewModel.Watermark

Remarks

A document can contain either text, or a picture as its watermark. The following properties are in effect for text watermarks only.

The following properties are in effect for picture watermarks only.

The Watermark toolbar button PrintPreviewBar.btnWatermark and the corresponding menu item are represented via the PrintingSystemCommand.Watermark printing system command. To change the visibility of these items the PrintingSystemBase.SetCommandVisibility method should be used.

Note

To assign a watermark object to the document, the Watermark.CopyFrom method should be used.

Example

This example demonstrates how to add a text watermark (the SetTextWatermark method) or an image watermark (the SetPictureWatermark method) to a printing system document.

using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.Drawing;
// ...
public void SetTextWatermark(PrintingSystem ps) {
    // Create the text watermark.
    Watermark textWatermark = new Watermark();

    // Set watermark options.
    textWatermark.Text = "CUSTOM WATERMARK TEXT";
    textWatermark.TextDirection = DirectionMode.ForwardDiagonal;
    textWatermark.Font = new DXFont(textWatermark.Font.Name, 40);
    textWatermark.ForeColor = Color.DodgerBlue;
    textWatermark.TextTransparency = 150;
    textWatermark.ShowBehind = false;
    textWatermark.PageRange = "1,3-5";

    // Set the watermark to a document.
    ps.Watermark.CopyFrom(textWatermark);
}
public void SetPictureWatermark(PrintingSystem ps) {
    // Create the text watermark.
    Watermark pictureWatermark = new Watermark();

    // Set watermark options.
    pictureWatermark.ImageSource = ImageSource.FromFile("Watermark.png");
    pictureWatermark.ImageAlign = ContentAlignment.TopCenter;
    pictureWatermark.ImageTiling = false;
    pictureWatermark.ImageViewMode = ImageViewMode.Stretch;
    pictureWatermark.ImageTransparency = 150;
    pictureWatermark.ShowBehind = true;
    pictureWatermark.PageRange = "2,4";

    // Set the watermark to a document.
    ps.Watermark.CopyFrom(pictureWatermark);
}

Inheritance

Object
DevExpress.Printing.Utils.DocumentStoring.StorableObjectBase
See Also