title: how to return pdf file result to ajax jquery and display it in new tab of browser
body: <p>I want to generate pdf using rdlc. I want to call it using ajax, it returns correct data but I dont know how to show it in browser.   </p>
  
  <pre><code>public class CustomerController 
  {
   //Render the report
   public FileResult PrintPOFILE(CustomerInputModel model)
      {
          //File generation logic
  
          renderedBytes = localReport.Render(
              reportType,
              deviceInfo,
              out mimeType,
              out encoding,
              out fileNameExtension,
              out streams,
              out warnings);
  
          //FileStream fs = new FileStream(filePath, FileMode.Create);
          using (FileStream fs = new FileStream(Server.MapPath("~/download/") + FileName + ".pdf", FileMode.Create))
          {
              fs.Write(renderedBytes, 0, renderedBytes.Length);
          }
  
          Response.ClearHeaders();
          Response.ClearContent();
          Response.Buffer = true;
          Response.Clear();
          Response.ContentType = "application/pdf";
          Response.AddHeader("Content-Disposition", "inline; filename=" + FileName + ".pdf;");
  
          Response.WriteFile(Server.MapPath("~/download/" + FileName + ".pdf"));
          Response.Flush();
          Response.Close();
          Response.End();
  
          string PdfUrl = Server.MapPath("~/download/" + FileName + ".pdf");
    return File(PdfUrl, "application/pdf");
      }
  
   [HttpPost]
      public ActionResult PrintFile(string Id)
      {
          int id = Convert.ToInt32(Id);            
          CustomerInputModel CustomerPrintModel = GetCustomer(id);           //function to get information of customer
          PrintPOFILE(CustomerPrintModel );
          return View(CustomerPrintModel );
      }
  </code></pre>
  
  <p>but when I call this function from ajax on button click,</p>
  
  <pre><code>  &lt;p&gt;
                  &lt;input type="button" value="Print PO" id="PrintBtn" name="button" /&gt;
              &lt;/p&gt;
   $("#PrintBtn").click(function (){
   var id = $("#Id").val();
       $.ajax({
              url: "/Customer/PrintFile",
              type: "POST",
              data: {Id : id},
              success: function (data) 
              {
                  alert(data);                        
  
                  window.open("http://localhost:51035/download/"+data,"_blank");
  
  
              }
          });
        //  alert("Print");
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>alert(data); shows unicode characters but I want pdf file to open in new tab of browser.
  I want this on button click like when I click the button, it should go to the url specified in ajax, on that action i called another function that returns file.</p>