当前位置: 首页 > 后端技术 > PHP

在线文档在线预览功能开发与分享(图书馆系统建设)

时间:2023-03-30 00:01:19 PHP

office/pdf文档版本预览(转png),无需安装任何插件,支持手机浏览,代码如下:/***文件转换//新版本*@return[type][description]*/publicfunctionget_convert(){error_reporting(0);ignore_user_abort();header('HTTP/1.1200OK');header('Content-Length:0');header('连接:关闭');冲洗();if(isset($_POST)&&$_POST['act']=='down'){/*获取文件路径*/$file_name=iconv("UTF-8","gb2312",$_POST['file_name']);如果(!file_exists($file_name)){返回false;}$type=pathinfo($file_name,PATHINFO_EXTENSION);$no_pdf='';/*if不是pdf文件需要转换成pdf*/if($type!='pdf'){$save_pdf='Public/files/upload_tmp/'.$_POST['user_id'];如果(!file_exists($save_pdf)){@mkdir($save_pdf,0777,true);}$pdf_name=pathinfo($file_name,PATHINFO_FILENAME);$filename=$save_pdf.'/'.$pdf_name.'.pdf';$source=dirname(dirname(dirname(dirname(__FILE__)))).'\\Public/'.$file_name;$export=dirname(dirname(dirname(dirname(__FILE__)))).'\\Public/'.$save_pdf;$num=D('文章')->lpdf($source,$filename,$export);//$num=D('文章')->turnPdf($file_name,$filename);//file_put_contents('get_api.txt',json_encode($source),FILE_APPEND);//file_put_contents('get_api.txt',json_encode($export),FILE_APPEND);//$num=D('PdfConverter')->execute($source,$export);$no_pdf='1';}else{$no_pdf='';$文件名=$文件名;//$num=D('文章')->getPdfPages($file_name);}//pdf转换成html$fileurl=dirname(dirname(dirname(dirname(__FILE__)))).'\\Public';$input_url=$fileurl.'/'.$filename;$output_url=$fileurl.'/Public/files/png/'.$_POST['user_id'].'/'.$_POST['article_id'];//file_put_contents('get_api.txt',$input_url,FILE_APPEND);//file_put_contents('get_api.txt',$output_url,FILE_APPEND);//$pdftohtml=D('Lc前端html5,back-end.net(注:前端是模仿风格,后端重写)(有问题可以私信我V:kjwenlc)图书馆系统主要实现文档共享功能,可以上传office文档和pdf文档。office文档支持多种版本未注册用户word和excel每个付费文档需要付费,注册用户只需要付费一次为每个付费文档下载此文档。