Jump to content

[SOLVED] Display PDF file inline -- how???


nloding

Recommended Posts

Here's what I want to do -- and I know it's possible, I just don't know how!

 

I want to click a link that points to http://mysite.com/pages/somthing.php?id=x.  Then I want to pull a filename from a database based on the key $_GET['id'].  I want that file (which is going to be a PDF) to then be displayed on the page.

 

HOWEVER!  I do not want to a Header redirect so that URL is the file itself -- I want the URL to remain http://.../something.php?id=x.  I've tried a ton of things I've found online, and none of them have worked.  The basics I've found are this:

 

<?
header("Pragma: public");
header("Expires: Thu, 29 May 2008 05:00:00 GMT");
header("Cache-Control: must-revalidate");
header("Content-type: application/pdf");
header("Content-Length: ".filesize($file));
header("Content-disposition: inline; filename=$file");
header("Accept-Ranges: ".filesize($file));
readfile($file);
exit();
?>

 

However, when I try that, it just sits there waiting on my webserver -- and my webserver isn't slow.  I have a function that does a similar thing with Content-disposition: attachment to force a Save As dialog and that works fine.

 

I've also tried using file read functions, and using a buffer ... notta!  I've been looking at PDFLib and FPDF but neither seem to have ways to open an EXISTING PDF, just create NEW PDF's.

 

Any help?

Link to comment
https://forums.phpfreaks.com/topic/107727-solved-display-pdf-file-inline-how/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.