Watermark Class
A document’s watermark.
Namespace: DevExpress.XtraPrinting.Drawing
Assembly: DevExpress.Printing.v17.2.Core.dll
Declaration
Related API Members
The following members accept/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.
- PageWatermark.Text;
- PageWatermark.TextDirection;
- PageWatermark.Font;
- PageWatermark.ForeColor;
- PageWatermark.TextTransparency.
The following properties are in effect for picture watermarks only.
- PageWatermark.Image;
- PageWatermark.ImageAlign;
- PageWatermark.ImageTiling;
- PageWatermark.ImageViewMode.
- PageWatermark.ImageTransparency.
The Watermark toolbar button 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 a watermark can be added to a printing system document. The SetTextWatermark method demonstrates the properties which are useful when a text watermark is added to a document, while the SetPictureWatermark method demonstrates the properties required to set a picture as the document’s watermark.
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 picture watermark.
Watermark pictureWatermark = new Watermark();
// Set watermark options.
pictureWatermark.Image = Bitmap.FromFile("watermark.gif");
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);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Watermark class.
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.