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

Straight to PDF with params?

2 Answers 133 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Geoff
Top achievements
Rank 1
Geoff asked on 24 Nov 2010, 01:54 PM
Hi there

I have seen the example on how to output reports straight to PDF but have a question....

Is it possible to send parameters using this method?

I would like to allow the user to 'run' the report but output straight to PDF - which I can do - but I do not know how to add a parameter in this context.

Can it be done?

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 26 Nov 2010, 06:03 PM
Hi Geoff,

Check out the following code snippet that illustrates how to set the report parameter value within the ExportToPDF method.

void ExportToPDF(Telerik.Reporting.Report reportToExport)
{
     reportToExport.ReportParameters["Parameter1"].Value = 1;
     reportToExport.ReportParameters["MultiValueParameter2"].Value = new object[] { 1, 2 };
 
    ReportProcessor reportProcessor = new ReportProcessor();
    RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);
       
    string fileName = result.DocumentName + ".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();
}


Greetings,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Geoff
Top achievements
Rank 1
answered on 26 Nov 2010, 06:15 PM
Thank you Peter -  that is very helpful and exaclty what I was looking to do.

All the best

Geoff
Tags
General Discussions
Asked by
Geoff
Top achievements
Rank 1
Answers by
Peter
Telerik team
Geoff
Top achievements
Rank 1
Share this question
or