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

WBOY
Release: 2016-06-13 12:47:43
Original
1046 people have browsed it

利用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);
Copy after login
 


错误提示:
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组件
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template