利用openoffice把office转成pdf,组件无法使用,请各位大侠帮忙。
本帖最后由 nationzhou 于 2013-05-18 16:42:24 编辑 php 利用openoffice把office转成pdf格式 问题请教
代码如下:
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, 0, $args);
$export_args = array(makepropertyvalue
(filtername,writer_pdf_export,$osm));
$owriterdoc->storetourl($output_url,$export_args);
$owriterdoc->close(true);
}
$output_dir = d:/apmserv5.2.6/www/htdocs/pdf/;
$doc_file = d:/apmserv5.2.6/www/htdocs/doc/abc.doc;
$pdf_file = abc.pdf;
$output_file = $output_dir . $pdf_file;
$doc_file = file:/// . $doc_file;
$output_file = file:/// . $output_file;
word2pdf($doc_file,$output_file);
错误提示:
fatal error: uncaught exception 'com_exception' with message 'failed to create com object `com.sun.star.servicemanager': 服务器运行失败 ' in d:\apmserv5.2.6\www\htdocs\phpinfo.php:13 stack trace: #0 d:\apmserv5.2.6\www\htdocs\phpinfo.php(13): com->com('com.sun.star.se...')
系统环境:apache, php5.2.6, php.ini已开启com,dcom ,
操作系统:win2003, 已安装过openoffice3.2, 已设置openoffice相关组件的访问权限,
已用命令行启动openoffice服务:
cd c:\program files\openoffice.org 3\program
c:\program files\openoffice.org 3\program>soffice -headless -accept=socket,host=127.0.0.1,port=8100;urp; -nofirststartwizard
仍然不能访问,页面大概运行一分钟才提示以上错误,望大侠能帮忙解决,万分感谢!
------解决方案--------------------
他已经告诉你创建 com.sun.star.servicemanager 服务失败了
这个与 php 没有关系
你需要先确认你的软件是否工作正常,即在 openoffice 中是否能够转换
如果能成功,再去检查 com+ 服务是否启动
