Watermark.CopyFrom(Watermark) Method

Duplicates the properties of the specified watermark object into the current instance of the Watermark class.

Namespace: DevExpress.XtraPrinting.Drawing

Assembly: DevExpress.Printing.v20.1.Core.dll

Declaration

public virtual void CopyFrom(
    Watermark watermark
)
Public Overridable Sub CopyFrom(
    watermark As Watermark
)

Parameters

Name Type Description
watermark Watermark

A Watermark object whose properties are to be copied.

Remarks

Use the CopyFrom method to duplicate the properties of the specified object into the instance of the Watermark class that this method is called from.

Examples

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;
// ...
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 Font(textWatermark.Font.FontFamily, 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);
}
See Also