title: Writing string content as PDF
body: <p>I have already build functionality to generate pdf file for reports that user view.</p>
  
  <p>So what it currently does is when user clicks to the print pdf button it</p>
  
  <ol>
  <li>Get the html content of the div that needs to be printed </li>
  <li>Send this content to the controller's method using jquery ajax method with POST</li>
  <li>In the controller it wraps the content with html document strings like <code>&lt;html&gt;</code>, <code>&lt;body&gt;</code> etc. plus I add some styles there.</li>
  <li>Then this html string is passed to one of the tools I am using that returns me pdf bytes for this string</li>
  <li>Then its saves those bytes as pdf file in a folder and returns the path of this file.</li>
  <li>Jquery then on success method opens up the window for this file's path.</li>
  </ol>
  
  <p>This all is working fine.</p>
  
  <p>The problem is</p>
  
  <ol>
  <li>It does not immediately opens up the window as it does all the processing and then on success it opens the window</li>
  <li>Plus I am wondering if I am doing this all correctly or doing some extra unnecessary steps, from this I mean is there any better way or short way to do this.</li>
  </ol>
  
  <p>Something like after getting content of div make some changes to the string to directly show it in the new window as pdf content etc. to avoid server processing, is that possible?</p>
  
  <p>Till now I have tried to show the content directly with <code>data:application/pdf</code> but that didn't work.</p>
  
  <p>If that is not possible, I am thinking to avoid saving of pdf file but just show the view that will open up as pdf, may be by setting its <code>content-type</code>, is that possible?</p>