Back to Devexpress

PageWatermark.ImageViewMode Property

corelibraries-devexpress-dot-xtraprinting-dot-drawing-dot-pagewatermark-8086e41c.md

latest5.3 KB
Original Source

PageWatermark.ImageViewMode Property

Gets or sets the mode in which a picture PageWatermark is displayed.

Namespace : DevExpress.XtraPrinting.Drawing

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
[DefaultValue(ImageViewMode.Clip)]
public ImageViewMode ImageViewMode { get; set; }
vb
<DefaultValue(ImageViewMode.Clip)>
Public Property ImageViewMode As ImageViewMode

Property Value

TypeDefaultDescription
ImageViewModeClip

An ImageViewMode enumeration value specifying how the picture should be displayed.

|

Available values:

NameDescription
Clip

The image is placed in the upper-left corner of the image control. The image is clipped if it’s larger than the image control which contains it.

| | Stretch |

The image within the image control is stretched or shrunk, as appropriate, to fit the size of the image control.

| | Zoom |

The image is sized proportionally (without clipping), so that it best fits the image control. If the height and width ratio of the image control is the same as the image’s ratio it will be resized to exactly fit into the image control. Otherwise, the closest fitting side (height or width) of the image will be sized to the control. The other side (height or width) of the image will be sized proportionally (leaving empty space).

|

Remarks

This member is in effect only for picture watermarks.

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.

csharp
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);
}
vb
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraPrinting.Drawing
Imports DevExpress.Drawing
' ...

Public Sub SetTextWatermark(ByVal ps As PrintingSystem)
   ' Create the text watermark.
   Dim textWatermark As 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)
End Sub

Public Sub SetPictureWatermark(ByVal ps As PrintingSystem)
   ' Create the picture watermark.
   Dim pictureWatermark As 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)
End Sub

See Also

PageWatermark Class

PageWatermark Members

DevExpress.XtraPrinting.Drawing Namespace