Watermark.PageRange Property
Gets or sets the range of pages which contain a watermark.
Namespace: DevExpress.XtraPrinting.Drawing
Assembly: DevExpress.Printing.v23.1.Core.dll
NuGet Packages: DevExpress.Printing.Core, DevExpress.Win.Dashboard.Design
Declaration
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | A String specifying the range of pages which contain a watermark. |
Remarks
The PageRange property’s value contains the range of pages on which a watermark is displayed. The ranges are separated by commas. For example: “1,3,5-12”.
Note
If not all pages from the specified page range exist in the current document, invalid page numbers are ignored. So, only valid page numbers are taken into account.
If there are no valid page numbers in the page range string, the watermark is added to all pages of the document.
Example
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;
using DevExpress.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 DXFont(textWatermark.Font.Name, 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);
}