Link to home
Start Free TrialLog in
Avatar of sscotti
sscottiFlag for United States of America

asked on

Displaying PDF embedded in PHP page with "Header", IE issue

I have a PHP page that dynamically displays a PDF page embedded within a PHP using Headers as follows:

<?php
include "database_functions.php";
$query="select * from pdf_files where pid = '".postUrlStringValue('pid',null)."'";
$res=mysql_query($query,getdbHandle());
$row = mysql_fetch_assoc($res);
extract($row);
$filename = str_replace(" ", "_", $name);
if (isset($pdfdata)) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-type: application/pdf");
header("Content-Disposition:inline; filename=\"$filename\"");
echo $pdfdata;
}
?>

The $pdfdata is actually coming from a database where the pdf is stored, atlhough I could put the pdf files on the server and reference them in the database.  I would prefer to keep them in a database though.

The pdf's display fine in Firefox and and Safari, but there is an error in IE where the new window will pup up for a second and then close itself, no data displayed.  Wondering if I need to change/adjust the headers, if it is a IE PDF Plug-in issue or what.  I did have a statement in there with the strlen($pdfdata) for the size of the file and that did not seem to make any difference.

Thanks.
Avatar of Kyle Hamilton
Kyle Hamilton
Flag of United States of America image

not sure about the IE thing, but for what it's worth, my understanding is that storing files in the database itself slows things down a lot, so maybe it's better to reference the pdf, which would inadvertently solve your problem anyway...

Cheers.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sscotti

ASKER

Ray,

In this instance I am more interested in actually displaying the pdf inline with a browser plug-in.  It works as is in FireFox and Safari on both the Mac and Windows (with plug-in for firefox on Windows).  The URL is sscotti.com and just select one of the drop down options to test.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Fugas
Fugas
Flag of Slovakia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial