您好,欢迎访问一九零五行业门户网

PHP实现在线阅读PDF

php如何实现在线阅读pdf?本文主要介绍了php实现在线阅读pdf文件的方法,十分的简单实用。希望对大家处理pdf有所帮助。
具体实现方法如下:
<?php if(!function_exists('read_pdf')) { function read_pdf($file) { if(strtolower(substr(strrchr($file,'.'),1)) != 'pdf') { echo '文件格式不对.'; return; } if(!file_exists($file)) { echo '文件不存在'; return; } header('content-type: application/pdf'); header('filename='.$file); readfile($file); } } read_pdf('python_study.pdf');
为了更好地用户体验,建议你前端采用 flexpaper在线显示文档组件来显示你的文档,先用pdf2swf工具将你的pdf转成flash文件,然后用 flexpaper来显示转换后的swf文件,这样用户浏览速度会很快,就像百度文库那样!
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <title></title> <script type="text/javascript" src="pdfobject.js"></script> <script type="text/javascript" src="jquery-1.8.0.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ //第一种方式 // var mypdf = new pdfobject({ url: "1.pdf" }).embed(); //第二种方式 var variablename = new pdfobject({ url: "1.pdf" }).embed("pdfobj"); //第三种方式 // var myembedparams = { // url: "1.pdf" // }; // var mypdf = new pdfobject(myembedparams).embed(); }); </script> </head> <body>asdfadsfasdf <p id="pdfobj"></p> </body> </html>
相关推荐:
php转换pdf为jpg
用php把word格式文件转换成pdf文件
使用html生成一个pdf实例代码
以上就是php实现在线阅读pdf的详细内容。
其它类似信息

推荐信息