首页 > 开发 > PHP > 正文

PHP实现在线阅读PDF文件的方法

2024-05-04 23:36:22
字体:大 中 小
来源:转载
供稿:网友

这篇文章主要介绍了PHP实现在线阅读PDF文件的方法,可实现在线读取并显示pdf文件的功能,需要的朋友可以参考下

本文实例讲述了PHP实现在线阅读PDF文件的方法。分享给大家供大家参考。具体实现方法如下:

 

 
  1. <?php 
  2. if(!function_exists('read_pdf')) { 
  3. function read_pdf($file) { 
  4. if(strtolower(substr(strrchr($file,'.'),1)) != 'pdf') { 
  5. echo '文件格式不对.'; 
  6. return; 
  7. } 
  8. if(!file_exists($file)) { 
  9. echo '文件不存在'; 
  10. return; 
  11. } 
  12. header('Content-type: application/pdf'); 
  13. header('filename='.$file); 
  14. readfile($file); 
  15. } 
  16. } 
  17. read_pdf('Python_study.pdf'); 

希望本文所述对大家的php程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表