这个示例展示了如何把水印添加到报表中。 SetTextWatermark 方法说明了在把文本水印添加到报表时非常有用的属性,而 SetPictureWatermark 方法则说明了在把图像设置为报表水印时必需的属性。

C#CopyCode image复制代码
using System.Drawing;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
// ...

public void SetTextWatermark(XtraReport report){
    // Adjust text watermark settings.
    report.Watermark.Text = "CUSTOM WATERMARK TEXT";
    report.Watermark.TextDirection = DirectionMode.ForwardDiagonal;
    report.Watermark.Font = new Font(report.Watermark.Font.FontFamily, 40);
    report.Watermark.ForeColor = Color.DodgerBlue;
    report.Watermark.TextTransparency = 150;
    report.Watermark.ShowBehind = false;
    report.Watermark.PageRange = "1,3-5";
}

public void SetPictureWatermark(XtraReport report){
    // Adjust image watermark settings.
    report.Watermark.Image = Bitmap.FromFile("watermark.gif");
    report.Watermark.ImageAlign = ContentAlignment.TopCenter;
    report.Watermark.ImageTiling = false;
    report.Watermark.ImageViewMode = ImageViewMode.Stretch;
    report.Watermark.ImageTransparency = 150;
    report.Watermark.ShowBehind = true;
    report.Watermark.PageRange = "2,4";
}
Visual BasicCopyCode image复制代码
Imports System.Drawing
Imports DevExpress.XtraPrinting.Drawing
Imports DevExpress.XtraReports.UI
' ...

Sub SetTextWatermark(report As XtraReport)
    ' Adjust text watermark settings.
    report.Watermark.Text = "CUSTOM WATERMARK TEXT"
    report.Watermark.TextDirection = DirectionMode.ForwardDiagonal
    report.Watermark.Font = New Font(report.Watermark.Font.FontFamily, 40)
    report.Watermark.ForeColor = Color.DodgerBlue
    report.Watermark.Transparency = 150
    report.Watermark.TextTransparency = 150
    report.Watermark.ShowBehind = False
    report.Watermark.PageRange = "1,3-5"
End Sub

Public Sub SetPictureWatermark(report As XtraReport)
    ' Adjust image watermark settings.
    report.Watermark.Image = Bitmap.FromFile("watermark.gif")
    report.Watermark.ImageAlign = ContentAlignment.TopCenter
    report.Watermark.ImageTiling = False
    report.Watermark.ImageViewMode = ImageViewMode.Stretch
    report.Watermark.ImageTransparency = 150
    report.Watermark.ShowBehind = True
    report.Watermark.PageRange = "2,4"
End Sub

Expand image参阅