Copy CodeThe code is as follows:
To achieve a similar function like Baidu Library needs a series of conversions, the general process would like to convert Word to PDF format, and then convert the PDF format into SWF format. The display on the Web page is actually SWF format content.
First convert Word to SWF, need to call COM components, can be converted through office or WPS, but I try not to succeed, finally through OpenOffice 4.0.0 conversion is successful, OpenOffice 4.0.0 support windows and Linux operating system, it is necessary to download OpenOffice First, the official web should have. Convert Word to PDF, like a document that supports the title of English, does not support Chinese name documents, you can rename the file to English first, convert the file into Chinese after conversion, and may need to start the OpenOffice service.
Verify that the service is turned on,
The code is as follows:
Copy CodeThe code is as follows:
Class runtime//page Execution time classes
{
private $starttime;//page Start execution time
private $stoptime;//page End Execution time
private $spendtime;//page execution takes time
function Getmicrotime ()//Gets the floating-point number that returns the current microsecond
{
List ($usec, $sec) =explode ("", Microtime ());
return (float) $usec + (float) $sec);
}
function start ()//page to start the execution of functions, return to start Page execution time
{
$this->starttime= $this->getmicrotime ();
}
function end ()//Displays the time the page was executed
{
$this->stoptime= $this->getmicrotime ();
$this->spendtime= $this->stoptime-$this->starttime;
Return round ($this->spendtime,10);
}
function display ()
{
$this->end ();
echo "Run time: ". Round ($this->spendtime,10)." Seconds
";
}
}
/* Call method */
$timer =new Runtime ();
$timer->start ();
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 ("Sure this 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 = "9.pdf";
$output _file = $output _dir. $pdf _file;
$doc _file = "file:///". $doc _file;
$output _file = "file:///". $output _file;
Word2pdf ($doc _file, $output _file);
$timer->end ();
$timer->display ();
?>
Take the time to analyze:
Converting a Word document of size 1.48M to PDF requires run time: 1.3652579784 seconds own computer is this time, own test
Second, convert PDF to SWF, need to use another software, swftools through code call cmd command, directly on the code
Class runtime//page Execution time classes
{
private $starttime;//page Start execution time
private $stoptime;//page End Execution time
private $spendtime;//page execution takes time
function Getmicrotime ()//Gets the floating-point number that returns the current microsecond
{
List ($usec, $sec) =explode ("", Microtime ());
return (float) $usec + (float) $sec);
}
function start ()//page to start the execution of functions, return to start Page execution time
{
$this->starttime= $this->getmicrotime ();
}
function end ()//Displays the time the page was executed
{
$this->stoptime= $this->getmicrotime ();
$this->spendtime= $this->stoptime-$this->starttime;
Return round ($this->spendtime,10);
}
function display ()
{
$this->end ();
echo "Run time: ". Round ($this->spendtime,10)." Seconds
";
}
}
/* Call method */
$timer =new Runtime ();
$timer->start ();
Calling system software
$command = "\" C:\Program files\swftools\pdf2swf.exe\ "-t C:\8.pdf-s flashversion=9-o C:\m.swf";
Echo $command;
EXEC ($command);
echo ' OK ';
$timer->end ();
$timer->display ();
?>
Converting a PDF that you just converted to a SWF file requires Elapsed time: 1.3119211197 seconds
Finally, the SWF file is displayed in the Web page, this step needs to introduce a number of JS files and other files, the code is not written, direct download, in my upload data
http://www.bkjia.com/PHPjc/328115.html www.bkjia.com true http://www.bkjia.com/PHPjc/328115.html techarticle Copy the code as follows: SPAN style= "font-family:arial, Helvetica, Sans-serif" implements a series of conversions like the Baidu Library, and the general process wants to convert word into ...