求助:php 用windows COM组件调用openoffice接口实现word转pdf文件报错

来源:互联网 发布:办公软件word 编辑:程序博客网 时间:2024/05/19 20:58

以下是代码:

<?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 = "c:/";  $doc_file = "c:/t.doc";  $pdf_file = "2.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 '<b>Source:</b> [automation bridge] <br/><b>Description:</b> com.sun.star.task.ErrorCodeIOException: ' in C:\ComsenzEXP\wwwroot\demo\index.php:17 Stack trace: #0 C:\ComsenzEXP\wwwroot\demo\index.php(17): variant->storeToURL('file:///c:/2.pd...', Array) #1 C:\ComsenzEXP\wwwroot\demo\index.php(26): word2pdf() #2 {main} thrown in C:\ComsenzEXP\wwwroot\demo\index.php on line 17



0 0