using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Reporting;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            var deviceInfo = new System.Collections.Hashtable();

            var reportPackager = new ReportPackager();
            var reportSource = new InstanceReportSource();
            using (var sourceStream = System.IO.File.OpenRead("../../SampleReport.trdp"))
            {
                var report = (Report)reportPackager.UnpackageDocument(sourceStream);
                report.DataSource = new Person("Test Person", 24242424, DateTime.Now);
                reportSource.ReportDocument = report;
            }



            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string fileName = result.DocumentName + "." + result.Extension;
            string path = "./";
            string filePath = System.IO.Path.Combine(path, fileName);

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
    }
}
