title: How to handle PDF file from Web API in AngularJS?
body: <p>I've this <code>Web API</code> post method to generate a PDF:</p>
  
  <pre><code>[HttpPost]
  [Route("api/pdf")]
  public HttpResponseMessage Post(CustomType type)
  {
      StreamContent pdfContent = PdfGenerator.GeneratePdf();
  
      HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
      response.Content = pdfContent;
      response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
      response.Content.Headers.ContentDisposition.FileName = "PDFName.pdf"
  
      return response;
  }
  </code></pre>
  
  <p>In AngularJS I would like to get this PDF-file like this:</p>
  
  <pre><code>$http.post("api/pdf", object).then(function (results) {
      var data = results.data;
  
      //TODO: got PDF, how to handle?
  
  }, function (results) {
      console.log(results);
  });
  </code></pre>
  
  <p>But how should I handle the PDF-data in AngularJS? On iPad I would like the PDF to gets opened, but if the file is downloaded or just opened on desktop doesn't matter.</p>
  
  <p><strong>EDIT1:</strong></p>
  
  <p>Using <a href="https://github.com/eligrey/FileSaver.js/" rel="noreferrer">SaveAS JS library</a> I'm able to make a working solution on desktop:</p>
  
  <pre><code>$http.post("api/pdf", object).then(function (results) {
      var data = results.data;
  
      var file = new Blob([data], { type: 'application/pdf' });
      saveAs(file, "test.pdf");
  
  }, function (results) {
      console.log(results);
  });
  </code></pre>
  
  <p>The file is being downloaded to my desktop directly, but this solution does, for some reason, not work in iOS. Nothing happens. See this <a href="http://jsfiddle.net/dennismadsen/zye0e5cg/3/" rel="noreferrer">JSFiddle</a>.</p>
  
  <p>Is there another way to display the PDF on my iPad without having to embed the file on my website?</p>