Render PDF Reports in .Net Web or Winforms
One thing to note – render is not the same as draw. This article assumes you are using purely .Net for reporting purposes. If you are using C1, Telerik, Crystal Reports or some others, these examples are not included, although I can at least tell you it definitely possible to do the same in all of these.
(converted from VB asp.net blog reference below to C#)
//this would return the .rdl report to a pdf and prompt the user for a download in their browser Warning warnings = null; string streamids = null; string mimeType = null; string encoding = null; string extension = null; byte bytes = null; bytes = ReportViewer1.ServerReport.Render("PDF", null, mimeType, encoding, extension, streamids, warnings); System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes); Response.ContentType = "Application/pdf"; Response.BinaryWrite(ms.ToArray()); Response.End();
In Winforms your syntax would be similar, except instead of writing to buffer and prompting user for download, you would probably prompt for a path to save first and then write to this location using File IO.
MSDN (ReportViewer WinForms), http://msdn.microsoft.com/en-us/library/aa337089.aspx
ASP.net (blogs), http://weblogs.asp.net/kyleholder/archive/2008/03/05/render-the-contents-of-a-reportviewer-control-directly-to-pdf.aspx