Skip to main content

Page.Watermark Property

Provides access to the current watermark on this page.

Namespace: DevExpress.XtraPrinting

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

Declaration

public PageWatermark Watermark { get; }

Property Value

Type Description
PageWatermark

A PageWatermark object which represents the current watermark.

Remarks

When a Document is generated, all its Document.Pages contain a watermark which is specified by the PrintingSystemBase.Watermarks property of a document’s printing system.

To specify individual watermarks for particular pages, use the Page.WatermarkId property or call the Page.AssignWatermark method.

Example

The following example demonstrates how to specify a unique watermark for different pages in a report. You can do it in the following ways:

Page.AssignWatermark takes priority over Page.WatermarkId.

If you want to remove the watermark from a particular page, pass a new empty watermark to the AssignWatermark method.

View Example

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
// ...

namespace DifferentWatermarks {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e) {
            // Create a report and assign a watermark to it.
            XtraReport1 report = new XtraReport1();
            report.Watermarks.Add(CreateTextWatermark("Common Watermark", "Watermark1"));
            report.Watermarks.Add(CreateTextWatermark("Second Page", "Watermark2"));
            report.CreateDocument();

            // Add a custom watermark to the second page.
            Page myPage = report.Pages[1];
            myPage.WatermarkId = "Watermark2";

            // Remove a watermark from the third page.
            myPage = report.Pages[2];
            myPage.AssignWatermark(new PageWatermark());

            // Show the Print Preview.
            report.ShowPreviewDialog();
        }

        // Create a watermark with the specified text.
        private Watermark CreateTextWatermark(string text, string id) {
            Watermark textWatermark = new Watermark();
            textWatermark.Id = id;
            textWatermark.Text = text;
            textWatermark.TextDirection = DirectionMode.ForwardDiagonal;
            textWatermark.Font = new DXFont(textWatermark.Font.Name, 40);
            textWatermark.ForeColor = Color.DodgerBlue;
            textWatermark.TextTransparency = 150;
            textWatermark.TextPosition = WatermarkPosition.InFront;
            return textWatermark;
        }

    }
}
See Also