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

Page.AssignWatermark(PageWatermark) Method

Assigns a new watermark to a page’s Page.Watermark property.

Namespace: DevExpress.XtraPrinting

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

Declaration

public void AssignWatermark(
    PageWatermark source
)

Parameters

Name Type Description
source PageWatermark

A PageWatermark object which specifies a new watermark for a page.

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 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;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the AssignWatermark(PageWatermark) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also