验证服务是否开启,上图
代码如下:
">
Home >Backend Development >PHP Tutorial >Convert word to swf and read the implementation ideas and code like Baidu Library_PHP Tutorial
<?php <BR>class RunTime//Page execution time class<BR>{ <BR>private $starttime;//Page starts execution Time<BR>private $stoptime;//Page end execution time<BR>private $spendtime;//Page execution time spent<BR>function getmicrotime()//Get the floating point number that returns the current microseconds<BR>{ <BR>list($usec,$sec)=explode(" ",microtime()); <BR>return ((float)$usec + (float)$sec); <BR>} <BR>function start() //The page starts executing the function and returns the time when the page execution started <BR>{ <BR>$this->starttime=$this->getmicrotime(); <br>} <br>function end()//Display Page execution time <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>Running time:".round($this->spendtime,10)."Seconds</p>"; <br>} <br>} <br>/*Call method*/ <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>?>
< ;/P>
Converting a 1.48M word document to pdf requiresRunning time: 1.3652579784 seconds This is the time on your own computer, test it yourself
Secondly, convert the pdf to swf , you need to use another software, swftools to call the cmd command through the code, directly enter the code
<?php <BR>class RunTime//Page execution time class<BR>{ <BR>private $starttime;//Page start execution time<BR>private $stoptime;//Page end execution time<BR>private $spendtime;//Page execution time <BR>function getmicrotime()//Get the floating point number that returns the current microsecond <BR>{ <BR>list($usec,$sec)=explode(" ",microtime()); <BR>return (( float)$usec + (float)$sec); <BR>} <BR>function start()//The page starts executing the function and returns the time to start the page execution<BR>{ <BR>$this->starttime= $this->getmicrotime(); <br>} <br>function end()//Display the page execution time<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>Running time: ".round($this->spendtime,10)." seconds< ;/p>"; <br>} <br>}<br>/*Calling method*/ <br>$timer=new Runtime(); <br>$timer->start(); <br><br><br>//Calling system software<br>$ command = ""C:Program FilesSWFToolspdf2swf.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>?>
The last step is to display the swf file on the web page. You need to import multiple js files and other files, so I won’t write the code, just download it directly from my uploaded information
< ;/P>