Exporting Report to PDF

2 posts, 0 answers
  1. Edwin
    Edwin avatar
    1 posts
    Member since:
    Jun 2016

    Posted 21 May 2018 Link to this post

    Hi All,

    Please I have been trying to export a standalone report in .trdp to pdf using the code below. but cant make any head away expecially with this line

           typeReportSource.TypeName = "ReportName";.

    Any help or assistance.

    Thanks

                        Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

                        // set any deviceInfo settings if necessary
                        System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();

                      Telerik.Reporting.TypeReportSource typeReportSource = new Telerik.Reporting.TypeReportSource();

                        // reportName is the Assembly Qualified Name of the report

                        typeReportSource.TypeName = "ReportName";


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

                        string fileName = result.DocumentName + "." + result.Extension;
                        string path = System.IO.Path.GetTempPath();
                        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);
                        }

  2. Travis
    Travis avatar
    4 posts
    Member since:
    Feb 2018

    Posted 21 May 2018 in reply to Edwin Link to this post

    The way you are trying to do this is reserved for a C# implementation and not using a trdp file, in which case it would be the Type's AssemblyQualifiedName which would be passed through to the TypeName.

    You want to use Telerik.Reporting.UriReportSource instead of Telerik.Reporting.TypeReportSource and specify the Uri to the trdp file.

    All the code you need can be found here: https://www.telerik.com/forums/loading-report-from-file

Back to Top