title: How best to export a grid to PDF in ASP.NET MVC
body: <p>I don't know that this is necessarily important, but I'm using Infragistics iggrid for my grid and their Reports stuff to export to PDF. </p>
  
  <p>The underlying issue I have is that my data that I want to export is in the browser and I would prefer that I don't have to create a server-side file to download. We have an icon on the screen that the user clicks to download the PDF.</p>
  
  <p>So what I'm doing on the client, is collecting all the data. This has to be done client-side because I want to export the data as the user has it sorted, filtered, and column-ordered (otherwise I could just collect the data server-side which would make this simpler). I then send the data to the server via a POST.</p>
  
  <p>On the server-side I generate the PDF file. Now, obviously, I could save the PDF server-side and redirect to the generated file, but that adds maintenance of temporary files which I'd prefer to avoid (but worst case, I can go there. Just fishing for options right now).</p>
  
  <p>I tried returning the data base64 encoded and then doing:</p>
  
  <p><code>window.open("data:application/pdf;base64," + encodedData);</code></p>
  
  <p>This doesn't work (at least in IE) because the URL limit is a bit over 2K.</p>
  
  <p>I tried using the downloadDataURI javascript function here: <a href="http://code.google.com/p/download-data-uri/" rel="nofollow">http://code.google.com/p/download-data-uri/</a></p>
  
  <p>But that only appears to work with Chrome (even after commenting out the webkit check) and I'm apparently not clever enough to figure out why.</p>
  
  <p>I'm sure I'm missing some obvious possibility that doesn't require creating a server-side file, but I'm just not seeing it. (disclaimer: My daughter woke me up horribly early this morning so the answer could be really trivial and I will feel stupid tomorrow when my brain is working).</p>