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

Export to PDF without using an HttpResponse - C#

2 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Landon
Top achievements
Rank 2
Landon asked on 15 Dec 2010, 11:29 PM
Hi,

I am currently creating a Function that will create separate Telerik Reports for each item in a List. I then need to export each Report to a PDF to a specific location behind the scenes, without launching an HttpResponse.

Is there a way to programmatically export a Telerik Report to a specific location without calling an HttpResponse?

Best Regards,

Landon

2 Answers, 1 is accepted

Sort by
0
Landon
Top achievements
Rank 2
answered on 16 Dec 2010, 12:07 AM
Sorry for the double-post,

But I ended up figuring this one out on my own, and thought I'd share my answer if anyone else stumbles upon this in the future.

I ended up writing a function using the ReportProcessor and the FileStream Methods. Here is an example of my code below:

protected void ReportExportToPDF(Telerik.Reporting.Report reportToExport, string name)
        {
            ReportProcessor reportProcessor = new ReportProcessor();
            RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);
 
            string filename = name;
 
            FileStream fs = new FileStream(filename, FileMode.Create);
            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            fs.Flush();
            fs.Close();
 
        }

Hope this helps someone else out!

PS:  @Admin, could you please mark this Thread as Answered.

Landon
0
Steve
Telerik team
answered on 16 Dec 2010, 08:38 AM
Hello Landon,

We're glad you were able to find a solution on your own. However this information is also available in our documentation since v.1.x. - here is the link: Exporting Report Programmatically.

All the best,
Steve
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
Tags
General Discussions
Asked by
Landon
Top achievements
Rank 2
Answers by
Landon
Top achievements
Rank 2
Steve
Telerik team
Share this question
or