title: Download PDF without saving in ASP.net Handler
body: <p>I've a handler in asp.net app. When there comes some kind of request I want user to get download window, where I put <strong>PDF</strong> stream. I don't want PDF to be saved in memory.
  I have the following code, but it fails to open, says pdf file was demaged and couldn't open it.
  tell me other way to achieve my goal if you think mine is not good.
  </p>
  
  <pre><code> MemoryStream stream = new MemoryStream();
                  CreatePFD(T.Text, stream);
  
                  context.Response.Write(stream);
  
  
                  context.Response.ContentType = "application/pdf";
                  context.Response.AddHeader("content-disposition", "attachment; filename=" + "Nots__Saved__FIle__fileName.pdf");
  </code></pre>
  
  <p>Now I have this code:
  </p>
  
  <p>Document Doc = new Document(PageSize.A4, 80, 50, 30, 65);
                  System.IO.Stream outputStream = new System.IO.FileStream(@"C:\inetpub\wwwroot\c\wefwe.pdf", System.IO.FileMode.OpenOrCreate);</p>
  
  <pre><code>            PdfWriter.GetInstance(Doc, outputStream);
  
              Doc.Open();
  
              List&lt;IElement&gt; htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(T.Text), null);
              for (int k = 0; k &lt; htmlarraylist.Count; k++)
              {
                  Doc.Add((IElement)htmlarraylist[k]);
              }
  
              outputStream.CopyTo(context.Response.OutputStream);
              Doc.Close();
  
              context.Response.ContentType = "application/pdf";
              context.Response.AddHeader("content-disposition", "attachment; filename=" + "Nots__Saved__FIle__fileName.pdf");
  </code></pre>
  
  <p>when i save pdf, the file is correct...
  but when I get response the file is in correct. demaged...</p>