加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php如何将word文档转化为pdf

发布时间:2020-05-25 01:05:08 所属栏目:PHP 来源:互联网
导读:本文是一个将word文档转化为pdf文件的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;

}

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);

?>

(编辑:安卓应用网)

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

    推荐文章
      热点阅读