PageWatermark.ImageAlignment Property
Gets or sets the position of the PageWatermark‘s picture. Use this property in non-Windows environments.
Namespace: DevExpress.XtraPrinting.Drawing
Assembly: DevExpress.Printing.v24.2.Core.dll
Declaration
[DefaultValue(ImageAlignment.MiddleCenter)]
public ImageAlignment ImageAlignment { get; set; }
Property Value
Type | Default | Description |
---|---|---|
ImageAlignment | MiddleCenter | An enumeration value that specifies how a picture is aligned on the document page. |
Available values:
Name | Description |
---|---|
Default | The default image alignment is used. |
TopLeft | An image is aligned to the top left corner of a control. |
TopCenter | An image is aligned to the top side of a control. |
TopRight | An image is aligned to the top right corner of a control. |
MiddleLeft | An image is aligned to the left side of a control. |
MiddleCenter | An image is aligned to the middle of a control. |
MiddleRight | An image is aligned to the right side of a control. |
BottomLeft | An image is aligned to the bottom left corner of a control. |
BottomCenter | An image is aligned to the bottom side of a control. |
BottomRight | An image is aligned to the bottom right corner of a control. |
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 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.ImageAlignment = ImageAlignment.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);
}