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:
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");
And this is the output 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);
}
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, <object>
doesn't work at all and <embed>
show's screwy plugin problems.
Any suggestions?