du131642 2010-06-04 10:01
浏览 33

使用php打开pdf文件

i wana open pdf file using php ,it works well but it prompt me for downloading that file in specified folder.. what i want to do is just by clicking a link pdf file get open without prompting for download.. anyone have idea about it?? thanx in advance.. below z the code

php code:

$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>
  • 写回答

2条回答 默认 最新

  • doudou130216 2010-06-04 10:21
    关注

    Remove header("Content-Disposition: inline; filename=gen01.pdf"); But if the visitor doesn't have a PDF Reader associated with the 'application/pdf' mime-type, the browser WILL download the file.

    评论

报告相同问题?

悬赏问题

  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏