Skip to content

Instantly share code, notes, and snippets.

@sitefinitysteve
Created July 24, 2020 15:21
Show Gist options
  • Save sitefinitysteve/7fd874150963a3e1ee4d0d91429b2bea to your computer and use it in GitHub Desktop.
Save sitefinitysteve/7fd874150963a3e1ee4d0d91429b2bea to your computer and use it in GitHub Desktop.
/blog/code/2012/03/16/telerik-reporting--export-on-button-click
void ExportToPDF(Telerik.Reporting.Report reportToExport)
{
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment