Page 1 of 1

Show Watermark on selected Pages

Posted: Fri May 20, 2011 1:26 am
by vorauler
Hello

I would show a watermark on selected pages on a report.
For that I use the BeforPrint event of the page object.

Code: Select all

Page1.Watermark.Enabled = Insurant.ShowWatermark;
Page1.Watermark.Text = Insurant.WatermarkText
The simplified code for printing is

Code: Select all

private void PrintReport()
{
   var data = new List();
   data.Add(new ReportPrintValue { Nachname = "Person1", Vorname = "Test", ShowWatermark = true, WatermarkText = "Person1 Watermark" });
   data.Add(new ReportPrintValue { Nachname = "Person2", Vorname = "Test", ShowWatermark = false });
   data.Add(new ReportPrintValue { Nachname = "Person3", Vorname = "Test", ShowWatermark = false });
   data.Add(new ReportPrintValue { Nachname = "Person4", Vorname = "Test", ShowWatermark = false });
   data.Add(new ReportPrintValue { Nachname = "Person5", Vorname = "Test", ShowWatermark = true, WatermarkText = "Person5 Watermark" });
   data.Add(new ReportPrintValue { Nachname = "Person6", Vorname = "Test", ShowWatermark = false });
   data.Add(new ReportPrintValue { Nachname = "Person7", Vorname = "Test", ShowWatermark = false });
   StiReport report = new StiReport();
   report.Load(Application.StartupPath + @"\\Watermark.mrt");

   report.Compile();
   report.RegData("Insurant", data);
   report.ShowWithRibbonGUI();
}

class ReportPrintValue
{
   public string Nachname { get; set; }
   public string Vorname { get; set; }
   public bool ShowWatermark { get; set; }
   public string WatermarkText { get; set; }
}
Now I thought I get a watermark on page1 and page5, but I get a watermark on page1, page2 and page6.

Can I use the watermark for my purposes or is there an other procedure to achive this?

Ralf

Show Watermark on selected Pages

Posted: Sat May 21, 2011 5:57 am
by Brendan
Do you get the behaviour you want if you use the Page Rendering event instead of the BeforePrint event?

Show Watermark on selected Pages

Posted: Sun May 29, 2011 11:22 pm
by vorauler
Thank you. This solved my problem.

Ralf