displaying a pdf
| From: | Jim Giner | Date: | Sun, 29 May 2011 21:02:07 +0000 |
| Subject: | displaying a pdf | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-313230@lists.php.net to get a copy of this message | ||
Perhaps someone can tell me what I'm doing wrong. I did some ( a lot)
looking around for hints on this and here is what I have compiled. It
doesn't work - just goes to a white, blank page and sits. I don't know if I
need all the html parts or even if I have placed my php in the right areas.
BTW - all I want to do is use a menu option to take me to a page that shows
the pdf. My menu (a js thing) won't let me use an <a> element, so I'm
trying to just build a php page that I can go to and display the doc
automacitcally without the user having to click on something..
[code begins]
<?php
session_start();
$root = $_SERVER['DOCUMENT_ROOT'];
$pdfname='/pdfs/myfile.pdf';
$length = filesize($pdfname);
//
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$pdfname);
header("Content-Length: ".$length);
//
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<?
readfile=$pdfname;
?>
</body>
</html>
[code ends]
Thanks in advance!