PageWatermark.ImageTransparency Property
Gets or sets the transparency of the watermark’s image.
Namespace: DevExpress.XtraPrinting.Drawing
Assembly: DevExpress.Printing.v24.1.Core.dll
NuGet Package: DevExpress.Printing.Core
Declaration
[TypeConverter(typeof(WatermarkImageTransparencyConverter))]
[XtraSerializableProperty]
public int ImageTransparency { get; set; }
Property Value
Type | Description |
---|---|
Int32 | An integer value specifying the images’s transparency. It should be between 0 and 255, inclusive. |
Remarks
This property specifies the watermark image’s transparency. Use the PageWatermark.Image property to access the watermark image.
Note
Transparency is not supported for SVG image watermarks. The ImageTransparency property’s value is ignored when you set an SVG file as a watermark image.
Example
This example demonstrates how to add a watermark to a printing system document. The SetTextWatermark method demonstrates the properties that are used to specify settings when a text watermark is added to a document, while the SetPictureWatermark method demonstrates the properties required to set a picture as a document’s watermark.
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.FontFamily, 40);
textWatermark.ForeColor = Color.DodgerBlue;
textWatermark.TextTransparency = 150;
textWatermark.TextPosition = WatermarkPosition.InFront;
textWatermark.PageRange = "1,3-5";
// Add the watermark to the collection.
ps.Watermarks.Add(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.ImagePosition = WatermarkPosition.Behind;
pictureWatermark.PageRange = "2,4";
// Add the watermark to the collection.
ps.Watermarks.Add(pictureWatermark);
}