我在网上下了一段代码,但是运行的时候出错。请教下怎么回事?谢了。错误:[code]Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `com.sun.star.ServiceManager': 服务器运行失败 ' in E:\Web\doc.xidian.cc\pdf.php:10 Stack trace: #0 E:\Web\doc.xidian.cc\pdf.php(10): com->com('com.sun.star.Se...') #1 E:\Web\doc.xidian.cc\pdf.php(25): word2pdf('file:///upload/...', 'file:///upload/...') #2 {main} thrown in E:\Web\doc.xidian.cc\pdf.php on line 10[/code]PHP代码: <?php
set_time_limit(0);
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 = "upload/";
$doc_file = "upload/1315192249.doc";
$pdf_file = "1315192249.pdf";
$output_file = $output_dir . $pdf_file;
$doc_file = "file:///" . $doc_file;
$output_file = "file:///" . $output_file;
word2pdf($doc_file,$output_file);
?>
set_time_limit(0);
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 = "upload/";
$doc_file = "upload/1315192249.doc";
$pdf_file = "1315192249.pdf";
$output_file = $output_dir . $pdf_file;
$doc_file = "file:///" . $doc_file;
$output_file = "file:///" . $output_file;
word2pdf($doc_file,$output_file);
?>
解决方案 »
- 招PHP开发工程师(上海)
- PHP+IIS+MYSQL搭建问题
- 《php面向对象初步入门教程pdf版》中用的软件是什么
- 播放器无法播放求高手
- php新手基础建议
- coreseek增量索引,建立索引后查不出结果
- 谈谈大家对网上一些教程资料的看法
- 哥哥姐姐们 你们帮我分析一下 你们学编程语言的技巧 和自学技巧 还有 学编程的方法 我这个人笨 老师讲的我会用 让我自己想我就楞了 我是不是欠缺一种方法啊 我是个初中毕业 呵呵
- 关于动态jpgraph图片的问题,在线等。
- 为什么 phpwrod 不能读取word文档里面的内容
- CRMvtigerCRMvtigerCRMvtigerCRMvtigerCRMvtigerCRMvtigerCRMvtiger
- 新手问一下【配置wamp服务器控制上传文件大小的设置】紧急!!!!!!
Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `com.sun.star.ServiceManager': 服务器运行失败 ' in E:\Web\doc.xidian.cc\pdf.php:10 Stack trace: #0 E:\Web\doc.xidian.cc\pdf.php(10): com->com('com.sun.star.Se...') #1 E:\Web\doc.xidian.cc\pdf.php(25): word2pdf('file:///upload/...', 'file:///upload/...') #2 {main} thrown in E:\Web\doc.xidian.cc\pdf.php on line 10