php用openoffice转换文档到pdf为什么有的文件可以有的不可以

俊杰sang 发布于 2013/01/12 14:21
阅读 2K+
收藏 0
<?php
/**
 * Created by JetBrains PhpStorm.
 * User: q
 * Date: 13-1-7
 * Time: 下午2:25
 * To change this template use File | Settings | File Templates.
 */
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){
    //Invoke the OpenOffice.org service manager
        $osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n");
    //Set the application to remain hidden to avoid flashing the document onscreen
        $args = array(MakePropertyValue("Hidden",true,$osm));
    //Launch the desktop
        $top = $osm->createInstance("com.sun.star.frame.Desktop");
    //Load the .doc file, and pass in the "Hidden" property from above
    $oWriterDoc = $top->loadComponentFromURL($doc_url,"_blank", 0, $args);
    //Set up the arguments for the PDF output
    $export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm));
    //Write out the PDF
    $oWriterDoc->storeToURL($output_url,$export_args);
    $oWriterDoc->close(true);
}
$doc_file = "file:///f:/571c9e50f0a557a2da3d5cc23cc13a8e.doc";
$output_file = 'file:///f:/dev/23.pdf';
word2pdf($doc_file,$output_file);

?>

使用这段来转换doc到pdf 

有的文件能一直成功

有的文件报错

加载中
0
俊杰sang
俊杰sang

好吧终结此贴  原来不是代码错误 

这几个文件openoffice压根就打不开 

wps,word2010都打开的好好的 搞不懂

0
李狗蛋leo
李狗蛋leo
能教我下是怎么使用的吗?
返回顶部
顶部