验证服务是否开启,上图
代码如下:
">
<?php <BR>class RunTime//页面执行时间类 <BR>{ <BR>private $starttime;//页面开始执行时间 <BR>private $stoptime;//页面结束执行时间 <BR>private $spendtime;//页面执行花费时间 <BR>function getmicrotime()//获取返回当前微秒数的浮点数 <BR>{ <BR>list($usec,$sec)=explode(" ",microtime()); <BR>return ((float)$usec + (float)$sec); <BR>} <BR>function start()//页面开始执行函数,返回开始页面执行的时间 <BR>{ <BR>$this->starttime=$this->getmicrotime(); <BR>} <BR>function end()//显示页面执行的时间 <BR>{ <BR>$this->stoptime=$this->getmicrotime(); <BR>$this->spendtime=$this->stoptime-$this->starttime; <BR>//return round($this->spendtime,10); <BR>} <BR>function display() <BR>{ <BR>//$this->end(); <BR>echo "<p>运行时间:".round($this->spendtime,10)."秒</p>"; <BR>} <BR>} <BR>/*调用方法 */ <BR>$timer=new Runtime(); <BR>$timer->start(); <br><br><BR>function MakePropertyValue($name,$value,$osm){ <BR>$oStruct = $osm->Bridge_GetStruct <BR>("com.sun.star.beans.PropertyValue"); <BR>$oStruct->Name = $name; <BR>$oStruct->Value = $value; <BR>return $oStruct; <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>$output_dir = "C:/"; <BR>$doc_file = "C:/t.doc"; <BR>$pdf_file = "9.pdf"; <BR>$output_file = $output_dir . $pdf_file; <BR>$doc_file = "file:///" . $doc_file; <BR>$output_file = "file:///" . $output_file; <BR>word2pdf($doc_file,$output_file); <br><br><BR>$timer->end(); <BR>$timer->display(); <br><br>?>
将一个大小为1.48M的word文档转化为pdf需要运行时间:1.3652579784秒 自己电脑是这个时间,自己测试
其次将pdf转化为swf,需要运用另外一个软件,swftools 通过代码调用cmd命令,直接上代码
<?php <BR>class RunTime//页面执行时间类 <BR>{ <BR>private $starttime;//页面开始执行时间 <BR>private $stoptime;//页面结束执行时间 <BR>private $spendtime;//页面执行花费时间 <BR>function getmicrotime()//获取返回当前微秒数的浮点数 <BR>{ <BR>list($usec,$sec)=explode(" ",microtime()); <BR>return ((float)$usec + (float)$sec); <BR>} <BR>function start()//页面开始执行函数,返回开始页面执行的时间 <BR>{ <BR>$this->starttime=$this->getmicrotime(); <BR>} <BR>function end()//显示页面执行的时间 <BR>{ <BR>$this->stoptime=$this->getmicrotime(); <BR>$this->spendtime=$this->stoptime-$this->starttime; <BR>//return round($this->spendtime,10); <BR>} <BR>function display() <BR>{ <BR>//$this->end(); <BR>echo "<p>运行时间:".round($this->spendtime,10)."秒</p>"; <BR>} <BR>} <BR>/*调用方法 */ <BR>$timer=new Runtime(); <BR>$timer->start(); <br><br><BR>//调用系统软件 <BR>$command = "\"C:\Program Files\SWFTools\pdf2swf.exe\" -t C:\8.pdf -s flashversion=9 -o C:\m.swf"; <BR>echo $command; <BR>exec($command); <BR>echo 'ok'; <br><br><BR>$timer->end(); <BR>$timer->display(); <br><br>?>
最后则是将swf文件显示在网页中,这一步需要引入多个js文件和其他文件,代码就不写了,直接下载,在我的上传资料中