验证服务是否开启,上图
 
代码如下:
">

Home >Backend Development >PHP Tutorial >Convert word to swf and read the implementation ideas and code like Baidu Library_PHP Tutorial

Convert word to swf and read the implementation ideas and code like Baidu Library_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 14:59:52993browse

Copy code The code is as follows:

Implementation Similar functions like Baidu Wenku require a series of conversions. The general process is to convert word into pdf format, and then convert pdf format into swf format. The content displayed on the web page is actually in swf format.

First of all, to convert word into swf, you need to call the com component. You can convert it through office or wps, but my attempts were unsuccessful. Finally, I converted it through OpenOffice 4.0.0. Success, OpenOffice 4.0.0 supports Windows and Linux operating systems, so you need to download openOffice first, which should be available on the official website. Convert word to pdf. It seems that it only supports documents with English titles. Documents with Chinese names are not supported. You can rename the file to English first, and then change the file to Chinese after conversion. You may also need to start the openoffice service, as shown above.
Convert word to swf and read the implementation ideas and code like Baidu Library_PHP Tutorial
Verify whether the service is enabled. The code above
Convert word to swf and read the implementation ideas and code like Baidu Library_PHP Tutorial
is as follows:
Copy the code The code is as follows :

<?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>

 





Spend time analyzing:

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&lt ;/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>?>


To convert the pdf just converted into a swf file, you need to use Running time: 1.3119211197 seconds


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>









www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328115.htmlTechArticleCopy the code as follows: SPAN style="FONT-FAMILY: Arial, Helvetica, sans-serif" is implemented like Baidu Similar functions like the library require a series of transformations. The general process is to convert word into...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn