Download crystal report as pdf
you can use the following method in any .net application for download crystal reports as pdf file.
private void DownloadReport(ReportDocument rpt,string appName)
{
DiskFileDestinationOptions crDiskFileDestinationOptions = new DiskFileDestinationOptions();
string _filePath = string.Format(“{0}{1}.pdf”, System.IO.Path.GetTempPath(), System.Guid.NewGuid());
//set ExportOptions properties
crDiskFileDestinationOptions.DiskFileName = _filePath;
rpt.ExportOptions.DestinationOptions = crDiskFileDestinationOptions;
rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
rpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
// Export the report
rpt.Export();
// The following code writes the pdf file to the Clients browser.
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = “application/pdf”;
Response.AppendHeader(“Content-Disposition”,”attachment; filename=” +appName+ “.pdf”);
Response.WriteFile(_filePath);
Response.Flush();
Response.Close();
// delete the exported file from disk
System.IO.File.Delete(_filePath);
}
-
Archives
- May 2011 (2)
- January 2011 (2)
- December 2010 (1)
- September 2010 (8)
- August 2010 (1)
- March 2010 (1)
- November 2009 (1)
- October 2009 (3)
- September 2009 (2)
- August 2009 (1)
- July 2009 (7)
- June 2009 (10)
-
Categories
-
RSS
Entries RSS
Comments RSS

