or
The watermark shows fine in the designer using Print Preview.
During runtime there is a crash.
<Watermarks>
<TextWatermark Text="= Elixir.App.Reports.DataSources.LoadIsPreliminary(Parameters.site.Value, Parameters.load_key.Value).ToString()" Color="Red" Orientation="Diagonal" Position="Front" Opacity="0.1" PrintOnFirstPage="True" PrintOnLastPage="True">
<Font Name="helvetica" Size="60pt" />
</TextWatermark>
</Watermarks>using Telerik.Reporting.Expressions;
namespace Elixir.App.Reports.DataSources
{
class BolFunctions: Telerik.Reporting.Report
{
/// <summary>
/// Is this load preliminary?
///
/// User function for Telerik reports
/// </summary>
/// <param name="site"></param>
/// <param name="loadKey"></param>
/// <returns></returns>
[Function(IsVisible = true, Category = "WatermarkTest", Description = "Testing", Namespace = "Elixir.App.Reports.DataSources", Name="LoadIsPreliminary")]
public static string LoadIsPreliminary(string site, string loadKey)
{
// Would actually prefer that this function return a bool
// and let the report output a non-blank watermark if true, otherwise no watermark.
// Would like to have another boolean function as well, LoadIsSpecialCase2, etc.
return "This is another test";
}
}
}
preferred watermark:<Watermarks>
<TextWatermark Text="= IIf(Elixir.App.Reports.DataSources.BolReportInfo.LoadIsPreliminary(Parameters.site.Value, Parameters.load_key.Value), "PRELIMINARY", 
 IIf(Elixir.App.Reports.DataSources.BolReportInfo.LoadIsCancelled(Parameters.site.Value, Parameters.load_key.Value), "CANCELLED", ""))" Orientation="Diagonal" Position="Front" Opacity="0.1" PrintOnFirstPage="True" PrintOnLastPage="True">
<Font Name="helvetica" Size="60pt" />
</TextWatermark>
</Watermarks>
ReportProcessor reportProcessor = new ReportProcessor();Hashtable deviceInfo = new Hashtable();var source = new InstanceReportSource { ReportDocument = report };RenderingResult result = reportProcessor.RenderReport( "PDF", source, deviceInfo );The type initializer for 'Telerik.Reporting.OpenXmlRendering.Wordprocessing.WordprocessingReport' threw an exception. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Telerik.Reporting.Processing.ExtensionManagerBase.CreateExtensionInfo(String typeName, String extensionName)Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 at Telerik.Reporting.OpenXmlRendering.Wordprocessing.WordprocessingReport..cctor()