ActiveReports For .NET to PDF Format In Browser

Here's a helpful little method if you are working with Data Dynamics ActiveReports.NET. It will take a report document passed in by reference and export the report in PDF format directly to the browser WITHOUT writing a file out to disk.

Here's a helpful little method if you are working with Data Dynamics ActiveReports.NET. It will take a report document passed in by reference and export the report in PDF format directly to the browser WITHOUT writing a file out to disk.


Here's a helpful little method if you are working with Data Dynamics ActiveReports.NET. It will take a report document passed in by reference
and export the report in PDF format directly to the browser WITHOUT writing
a file out to disk.

Please take a moment to rate this Tip (opens in new window):

http://www.turnkeytools.com/polls/default.asp?POLLID=10000061&DOMAINID=4610

public void WriteReportToBrowser(ref DataDynamics.ActiveReports.Document.Document oDoc)
{

MemoryStream oStream = new MemoryStream();
DataDynamics.ActiveReports.Export.Pdf.PdfExport oPDF = new DataDynamics.ActiveReports.Export.Pdf.PdfExport();

oPDF.Export(oDoc,oStream);

System.Web.HttpContext.Current.Response.Buffer = true;
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.ContentType = "application/pdf";
System.Web.HttpContext.Current.Response.BinaryWrite(oStream.ToArray());
System.Web.HttpContext.Current.Response.End();
oStream.Close();

}

By Robbe Morris   Popularity  (588 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of NullSkull.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP