Jump to content
Larry Ullman's Book Forums

Opening A Pdf In A Web Page


Recommended Posts

Hello,

 

Does anyone know whether it's possible to open a PDF file within a web page using PHP (or even JavaScript)?

 

I need to make a magazine viewer without using Flash (thanks to the iphone/ipad), so I was hoping that the original PDF could be accessed directly.

 

Thanks,

 

Jon

Link to comment
Share on other sites

It is possible, not that I have tested it.

// Send the content information:
header('Content-type:application/pdf');
header('Content-Disposition:inline;filename="' . $filename . '"');
$fs = filesize($file);
header ("Content-Length:$fs\n");
// Send the file:
readfile ($file);
exit();

Replace $filename with your filename and $file with the path and filename to the requested file.

Please look at Larry's E-Commerce book/files for more information

Link to comment
Share on other sites

PHP is a server-side technology, so it can't be used to do anything within the client. The tough thing here is the requirement that the PDF be opened within the HTML page. In a separate window is easy to do, as Craig posted. Within an HTML page, I know Flash can do it, but you don't want Flash. I'm not sure if JavaScript can do it, because you'd need a PDF plug-in somehow.

Link to comment
Share on other sites

 Share

×
×
  • Create New...