我在网上下了一段代码,但是运行的时候出错。请教下怎么回事?谢了。错误:[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);
?>
解决方案 »
- 散分! 搞it真没地位,越来越失望了.
- Fatal error: Class 'Mage_Adminhtml_Controller_action' not found
- 如何在自己的网站上添加万网邮箱登陆
- jquery做分页
- 谁知道PHPCMS2008新建好的"模板"在哪里调用吗?怎么调用吗?
- 关于MYSQL数据库操作的问题——超简单直接轻松拿70分
- 刚学习php 请教一个简单问题
- php arclist标签,截取字符怎么在后面加上点点点
- 有没有离线版的lamp一键安装包
- php开源的c2c系统 大家推荐几个啊 越详细越好
- 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