这个示例展示了如何把水印添加到报表中。 SetTextWatermark 方法说明了在把文本水印添加到报表时非常有用的属性,而 SetPictureWatermark 方法则说明了在把图像设置为报表水印时必需的属性。
C# | 复制代码 |
---|
using System.Drawing;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
public void SetTextWatermark(XtraReport report){
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){
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 Basic | 复制代码 |
---|
Imports System.Drawing
Imports DevExpress.XtraPrinting.Drawing
Imports DevExpress.XtraReports.UI
Sub SetTextWatermark(report As XtraReport)
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)
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
|
参阅