title: return PDF in ajax request
body: <p>I have got an ajax request to my Server where i am creating an PDF File. Now i want to display this file in a new window/tab or just download it. how can i do that?</p>
  
  <p>my request</p>
  
  <pre><code>$.ajax({
      url: '/Document/CreatePDF',
      type: 'POST',
      data: {
          docid: documentId,
          dataId: array
      },
      traditional: true,
      success: function (data) {
      }
  });
  
      [HttpPost]
      public FileStreamResult CreatePDF(long docid, List&lt;long&gt; dataId)
      {
          var document = _rep.LoadDocument(docid.ToString(), Server.MapPath("~/Documents/") + docid + ".xml");
  
          var exporter = new PDFExporter(document);
  
          MemoryStream fileStream = exporter.CreatePDF();
          byte[] PdfByte = fileStream.GetBuffer();
          fileStream.Flush();
          fileStream.Close();
  
          HttpContext.Response.AddHeader("content-disposition","attachment; filename=form.pdf");
  
          return new FileStreamResult(fileStream, "application/pdf");
      }
  </code></pre>