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

how to convert report to pdf in programmatically

2 Answers 199 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
shanker bangari
Top achievements
Rank 1
shanker bangari asked on 11 Jun 2010, 01:08 PM
Hi,

I want export report to pdf in programmatically in button click event . That pdf file window open on browser .So  how to solve this problem .I want  solution of this .Am writing this code .But it's not wroking .
 var report = new TelerikComponentsWS.Reports.RepFeeReceipt(); 
                report.DataSource = printdata; 
                Telerik.Reporting.Drawing.ExternalStyleSheet exx = new Telerik.Reporting.Drawing.ExternalStyleSheet("~\\css\\ReprotStyleSheet.xml"); 
                report.ExternalStyleSheets.Add(exx); 
                report.ReportParameters[0].Value = strTitle; 
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); 
                Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", report, null); 
                
             string fileName= result.DocumentName + ".pdf";  
            System.Web.HttpContext.Current.Response.Clear() ; 
                System.Web.HttpContext.Current.Response.ContentType = result.MimeType;   
            System.Web.HttpContext.Current.Response.Cache.SetCacheability( System.Web.HttpCacheability.Private) ;  
            System.Web.HttpContext.Current.Response.Expires = -1  ; 
            System.Web.HttpContext.Current.Response.Buffer =true

2 Answers, 1 is accepted

Sort by
0
Sivam
Top achievements
Rank 1
answered on 14 Jun 2010, 03:03 PM
Hi Shanker,

Try this.

void ExportToPDF(Telerik.Reporting.Report reportToExport, string name)  
 
{  
 
ReportProcessor reportProcessor = new ReportProcessor();  
 
RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);  
 
string fileName = name + ".pdf";  
 
Response.Clear();  
 
Response.ContentType = result.MimeType;  
 
Response.Cache.SetCacheability(HttpCacheability.Private);  
 
Response.Expires = -1;  
 
Response.Buffer = true;  
 
Response.AddHeader("Content-Disposition",  
 
string.Format("{0};FileName=\"{1}\"",  
 
"attachment",  
 
fileName));  
 
Response.BinaryWrite(result.DocumentBytes);  
 
Response.End();  
 
}  
 
0
shanker bangari
Top achievements
Rank 1
answered on 15 Jun 2010, 05:23 AM
Hi

Thank You for Your response .That's code all so same problem not working .
Tags
General Discussions
Asked by
shanker bangari
Top achievements
Rank 1
Answers by
Sivam
Top achievements
Rank 1
shanker bangari
Top achievements
Rank 1
Share this question
or