脚本宝典收集整理的这篇文章主要介绍了PHP调用OpenOffice实现word转PDF的方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
最近一直在研究PHP word文档转PDF,也在网上搜索了很多类似的资料,大多数都是通过OPEnOffice进行转换的。
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));
$oWriterDoc->StoreToURL($output_url,$export_args);
$oWriterDoc->close(true);
}$doc_file=dirname(FILE)."/11.doc"; //源文件,DOC或者WPS都可以
$output_file=dirname(FILE)."/11.pdf"; //欲转PDF的文件名
$doc_file = "file:///" . $doc_file;
$output_file = "file:///" . $output_file;
$document->word2pdf($doc_file,$output_file);
以上是脚本宝典为你收集整理的PHP调用OpenOffice实现word转PDF的方法全部内容,希望文章能够帮你解决PHP调用OpenOffice实现word转PDF的方法所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。