jonpugh114 Posted September 26, 2011 Share Posted September 26, 2011 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 More sharing options...
Craig-UK Posted September 26, 2011 Share Posted September 26, 2011 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 More sharing options...
Larry Posted September 26, 2011 Share Posted September 26, 2011 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 More sharing options...
jonpugh114 Posted September 28, 2011 Author Share Posted September 28, 2011 Thanks for that, it looks like I might have to show the pages using images, which will make my life easier. Cheers, Jon Link to comment Share on other sites More sharing options...
Recommended Posts