Progress® Telerik® Reporting R2 2017

Modify exported report document prior serving it to the viewer client

As of Telerik Reporting R3 2016 we introduced a points granting you access to rendered reports before providing them to the client.

In the following code snippets is demonstrated how to modify a report rendered in PDF format from desktop report viewers or service prior serving the report to the viewer client. The code snippets cover both desktop viewers and web viewers.

Desktop Viewers

Open the Windows Form or WPF Window code behind (F7) and handle report viewer ExportEnd as shown in the following snippet:

public ReportViewerFormOrWindow()
{
    InitializeComponent();
    this.reportViewer1.ExportEnd += ReportViewer1ExportEnd;
}

private void ReportViewer1ExportEnd(object sender, 
                                    Telerik.ReportViewer.Common.ExportEndEventArgs args)
{
    if(args.DocumentExtension.Equals("pdf"))  
    {  
      //modify the rendered document in args.DocumentBytes 
    } 
}

Web Viewers

In case you use Web viewer you have to overide the Telerik Reporting service OnGetDocument:

Web API

OnGetDocument

public class ReportController : Telerik.Reporting.Services.WebApi.ReportsControllerBase
{
    protected override void OnGetDocument(Telerik.Reporting.Services.GetDocumentEventArgs args)
    {
        if(args.Extension.Equals("pdf"))  
        {  
          //modify the rendered document in args.DocumentBytes 
        } 
    }
}

ServiceStack

OnGetDocument

public class ReportController : Telerik.Reporting.Services.WebApi.ReportsControllerBase
{
    protected override void OnGetDocument(Telerik.Reporting.Services.GetDocumentEventArgs args)
    {
        if(args.Extension.Equals("pdf"))  
        {  
          //modify the rendered document in args.DocumentBytes 
        } 
    }
}