Home >Backend Development >PHP Tutorial >利用openoffice把office转成pdf,组件无法使用,请诸位大侠帮忙

利用openoffice把office转成pdf,组件无法使用,请诸位大侠帮忙

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:02:201065browse

利用openoffice把office转成pdf,组件无法使用,请各位大侠帮忙。

本帖最后由 nationzhou 于 2013-05-18 16:42:24 编辑 php 利用openoffice把office转成pdf格式 问题请教
代码如下:

function MakePropertyValue($name,$value,$osm){  <br />	$oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");  <br />	$oStruct->Name = $name;  <br />	$oStruct->Value = $value;  <br />	return $oStruct;  <br />}<br /><br />function word2pdf($doc_url, $output_url){  <br />	$osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.n");  <br />	$args = array(MakePropertyValue("Hidden",true,$osm));  <br />	$oDesktop = $osm->createInstance("com.sun.star.frame.Desktop");  <br />	$oWriterDoc = $oDesktop->loadComponentFromURL<br />	($doc_url,"_blank", 0, $args);  <br />	$export_args = array(MakePropertyValue<br />	("FilterName","writer_pdf_Export",$osm));  <br />	$oWriterDoc->storeToURL($output_url,$export_args);  <br />	$oWriterDoc->close(true);  <br />}<br /><br />$output_dir = "D:/APMServ5.2.6/www/htdocs/pdf/";  <br />$doc_file = "D:/APMServ5.2.6/www/htdocs/doc/abc.doc";  <br />$pdf_file = "abc.pdf";  <br />$output_file = $output_dir . $pdf_file;  <br />$doc_file = "file:///" . $doc_file;  <br />$output_file = "file:///" . $output_file;<br /><br />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+ 服务是否启动
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:新浪微博登陆有关问题Next article:求htaccess守则