Exemplo n.º 1
0
        //------------------------------------------------------------------------------------------07.03.2005
        /// <summary>Sends the specified report to the browser.</summary>
        /// <param name="report">Report object that creates the PDF document</param>
        /// <param name="page">Page that has requested this report</param>
        /// <exception cref="ReportException">
        /// The acrobat reader has not been installed, the registry entry is invalid or the reader cannot be started.
        /// </exception>
        /// <remarks>
        /// This method will create the specified PDF document.
        /// The resulting stream will be sent to the browser.
        /// </remarks>
        /// <example>
        /// <code>
        /// &lt;%@ Page language="c#" Debug="true" ContentType="application/pdf" %&gt;
        /// &lt;%@ Import namespace="Root.Reports" %&gt;
        /// &lt;%@ Import namespace="ReportSamples" %&gt;
        /// &lt;script runat="server" language="C#"&gt;
        ///   void Page_Load() {
        ///     RT.ResponsePDF(new TableLayoutManagerSample(), this);
        ///   }
        /// &lt;/script&gt;
        /// </code>
        /// </example>
    #if !WindowsCE
        public static void ResponsePDF(Report report, System.Web.UI.Page page)
        {
            page.Response.Clear();
            page.Response.ContentType = "application/pdf";

            if (!(report.formatter is PdfFormatter))
            {
                throw new ReportException("PDF formatter required");
            }
            if (report.page_Cur == null)
            {
                report.Create();
            }

            report.formatter.Create(report, page.Response.OutputStream);
            page.Response.End();
        }
Exemplo n.º 2
0
        public static void ResponsePDF(Report report, System.Web.HttpResponse response)
        {
            if (report.formatter == null)
            {
                report.Init(new PdfFormatter());
            }
            if (report.page_Cur == null)
            {
                report.Create();
            }
            response.ClearContent();
            response.ContentType = "application/pdf";
            MemoryStream ms = new MemoryStream(20000);

            report.formatter.Create(report, ms);
            ms.Close();

            response.BinaryWrite(ms.GetBuffer());
            response.End();
        }