我wana打開PDF文件使用PHP,它運作良好,但它提示我下載該文件在指定的文件夾..我想要做的只是通過單擊一個鏈接的PDF文件打開沒有提示下載..任何人都有想法嗎?感謝名單提前..下面z上的代碼使用php打開pdf文件
PHP代碼:
$mypdf = PDF_new();
PDF_open_file($mypdf, "");
PDF_begin_page($mypdf, 595, 842);
$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);
PDF_setfont($mypdf, $myfont, 10);
PDF_show_xy($mypdf, "hello my first pdf converted file", 50, 750);
PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730);
PDF_end_page($mypdf);
PDF_close($mypdf);
$mybuf = PDF_get_buffer($mypdf);
$mylen = strlen($mybuf);
header("Content-type: application/pdf");
header("Content-Length: $mylen");
header("Content-Disposition: inline; filename=gen01.pdf");
print $mybuf;
PDF_delete($mypdf);
.....................................
html code:
<html>
<body>
Click here to see pdf file <a href="gen01.php" target="_blank">pdf1</a>
</body>
</html>
嗯,這將取決於客戶端瀏覽器(以及瀏覽器插件)。所以你不能確定它會顯示/打開。 – Macmade 2010-06-04 10:11:28