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+ 服务是否启动
他已经告诉你创建 com.sun.star.servicemanager 服务失败了
这个与 php 没有关系
你需要先确认你的软件是否工作正常,即在 openoffice 中是否能够转换
如果能成功,再去检查 com+ 服务是否启动
在openoffice中能打开doc文档,并可导出为pdf文件
在控制面板->管理工具->组件服务中:
右侧查找组件服务->计算机->我的电脑下
com+应用程序下没找到相关组件
dcom配置下找到两项:
1.openoffice.org 1.1文本文档
2.openoffice.org.service.manager
设置上两项组件属性->安全->启动和激活权限,这里添加了guest。如有其它需设置的地方请指教,不胜感激! 重装最新版的openoffice 3.4.1问题解决!搞了一天,靠!
在这里还是谢谢唠叨大侠的帮助!
为什么我按照上面照抄 点击php的时候没有反应?