This is a migrated thread and some comments may be shown as answers.

Exporting Report to PDF

1 Answer 698 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Edwin
Top achievements
Rank 1
Edwin asked on 21 May 2018, 06:08 PM

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);
                    }

1 Answer, 1 is accepted

Sort by
1
Travis
Top achievements
Rank 1
answered on 21 May 2018, 10:32 PM

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

Tags
General Discussions
Asked by
Edwin
Top achievements
Rank 1
Answers by
Travis
Top achievements
Rank 1
Share this question
or