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

Page.Watermark Property

Provides access to the current watermark on this page.

Namespace: DevExpress.XtraPrinting

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

Declaration

[XtraSerializableProperty(XtraSerializationVisibility.Content)]
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.Watermark property of a document’s printing system. However, you’re able to specify a custom watermark for a particular page via the Page.AssignWatermark method.

Example

The following example demonstrates how to specify a unique watermark for different pages in a report. For this you need to call the Page.AssignWatermark method for the page whose watermark needs to be changed, and pass a new watermark to this method as a parameter, as shown below. If you need to remove a watermark from a particular page, pass a new empty watermark to the AssignWatermark method.

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

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

    // Add a custom watermark to the second page.
    Page myPage = report.Pages[1];
    myPage.AssignWatermark(CreateTextWatermark("Second Page"));

    // 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) {
    Watermark textWatermark = new Watermark();

    textWatermark.Text = text;
    textWatermark.TextDirection = DirectionMode.ForwardDiagonal;
    textWatermark.Font = new Font(textWatermark.Font.FontFamily, 40);
    textWatermark.ForeColor = Color.DodgerBlue;
    textWatermark.TextTransparency = 150;
    textWatermark.ShowBehind = false;

    return textWatermark;
}
See Also