加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php如何将word文档转化为pdf

发布时间:2020-12-13 05:17:57 所属栏目:PHP教程 来源:网络整理
导读:代码如下: ? ? set_time_limit(0); ? ? function MakePropertyValue($name,$value,$osm){ ? ? $oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue"); ? ? $oStruct->Name = $name; ? ? $oStruct->Value = $value; ? ? return $oStruct;

代码如下:

? ? set_time_limit(0);

? ? function MakePropertyValue($name,$value,$osm){

? ? $oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");

? ? $oStruct->Name = $name;

? ? $oStruct->Value = $value;

? ? return $oStruct;

? ? }

? ? function word2pdf($doc_url,$output_url){

? ? $osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.n");

? ? $args = array(MakePropertyValue("Hidden",true,$osm));

? ? $oDesktop = $osm->createInstance("com.sun.star.frame.Desktop");

? ? $oWriterDoc = $oDesktop->loadComponentFromURL($doc_url,"_blank",$args);

? ? $export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm));

? ? //print_r($export_args);

? ? $oWriterDoc->storeToURL($output_url,$export_args);

? ? $oWriterDoc->close(true);

? ? }

? ? $output_dir = "C:/wamp/www/projectfolder/";

? ? $doc_file = "C:/wamp/www/projectfolder/wordfile.docx";

? ? $pdf_file = "outputfile_name.pdf";

? ? $output_file = $output_dir . $pdf_file;

? ? $doc_file = "file:///" . $doc_file;

? ? $output_file = "file:///" . $output_file;

? ? word2pdf($doc_file,$output_file);

? ? ?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读