title: Displaying 'dynamic' (php generated) PDF in a DIV or iFrame
body: <p>I'm having trouble with displaying PDF file in a div or iFrame.
  PDF files contain private information so i cant give direct access to this files. 
  I'm reading file with PHP and then `feeding' it to the browser.
  I'm using these headers:</p>
  
  <pre><code>    header('Content-Type: application/pdf');
      header('Content-Disposition: attachment; filename="myPdf.PDF"');
      header("Content-Transfer-Encoding: binary");
      header('Accept-Ranges: bytes');
      header("Cache-control: private");
      header('Pragma: private');
      header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  </code></pre>
  
  <p>And this is the output code:</p>
  
  <pre><code>    @ob_end_clean();
      if ($file_h = fopen($file, 'r'))
      {
  
          while (!feof($file_h))
          {
              $buffer = fread($file_h, filesize($file));
              print($buffer); 
              flush();
          }
          fclose($file_h);
      }
  </code></pre>
  
  <p>Apparently this is ideal for downloading files but now i need to load them in a DIV or iFrame. And it just doesn't work. iFrame does a download dialog, <code>&lt;object&gt;</code> doesn't work at all and <code>&lt;embed&gt;</code> show's screwy plugin problems.</p>
  
  <p>Any suggestions?</p>