一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

將word轉化為swf 如同百度文庫般閱讀實現思路及代碼

復制代碼 代碼如下:
<SPAN style="FONT-FAMILY: Arial, Helvetica, sans-serif">實現如同百度文庫那樣類似功能需要進行一系列轉化,一般流程想將word轉化為pdf格式,再將pdf格式轉化為swf格式。在網頁上顯示其實都是swf格式內容。</SPAN>

首先將word轉化為swf,需要調用com組件,可以通過office 或者wps進行轉化,但我嘗試都沒有成功,最后通過OpenOffice 4.0.0 進行轉化才成功,OpenOffice 4.0.0支持windows 和linux操作系統,故需要先下載openOffice,官網上應該有。將word轉化為pdf,好像只是支持英文的標題的文檔,不支持漢文名字文檔,可以先將文件重新命名為英文,轉化之后再將文件變為漢文即可,可能還需要開始openoffice 服務,上圖
 
驗證服務是否開啟,上圖
 
代碼如下:
復制代碼 代碼如下:
<PRE class=php name="code"><?php
class RunTime//頁面執行時間類
{
private $starttime;//頁面開始執行時間
private $stoptime;//頁面結束執行時間
private $spendtime;//頁面執行花費時間
function getmicrotime()//獲取返回當前微秒數的浮點數
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()//頁面開始執行函數,返回開始頁面執行的時間
{
$this->starttime=$this->getmicrotime();
}
function end()//顯示頁面執行的時間
{
$this->stoptime=$this->getmicrotime();
$this->spendtime=$this->stoptime-$this->starttime;
//return round($this->spendtime,10);
}
function display()
{
//$this->end();
echo "<p>運行時間:".round($this->spendtime,10)."秒</p>";
}
}
/*調用方法 */
$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 ("Please be sure that 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();

?></PRE><BR>
<P></P>
<PRE></PRE>
<P></P>
<P><BR>
</P>
花費時間進行分析:
<P>將一個大小為1.48M的word文檔轉化為pdf需要<SPAN style="FONT-FAMILY: Simsun; FONT-SIZE: 14px">運行時間:1.3652579784秒</SPAN> 自己電腦是這個時間,自己測試</P>
<P><BR>
</P>
<P>其次將pdf轉化為swf,需要運用另外一個軟件,swftools  通過代碼調用cmd命令,直接上代碼</P>
<P><PRE class=php name="code"><?php
class RunTime//頁面執行時間類
{
private $starttime;//頁面開始執行時間
private $stoptime;//頁面結束執行時間
private $spendtime;//頁面執行花費時間
function getmicrotime()//獲取返回當前微秒數的浮點數
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()//頁面開始執行函數,返回開始頁面執行的時間
{
$this->starttime=$this->getmicrotime();
}
function end()//顯示頁面執行的時間
{
$this->stoptime=$this->getmicrotime();
$this->spendtime=$this->stoptime-$this->starttime;
//return round($this->spendtime,10);
}
function display()
{
//$this->end();
echo "<p>運行時間:".round($this->spendtime,10)."秒</p>";
}
}
/*調用方法 */
$timer=new Runtime();
$timer->start();


//調用系統軟件
$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();

?></PRE><BR>
將剛才轉化而來的pdf轉化為swf文件需要用<SPAN style="FONT-FAMILY: Simsun; FONT-SIZE: 14px">運行時間:1.3119211197秒時間</SPAN><P></P>
<P><SPAN style="FONT-FAMILY: Simsun; FONT-SIZE: 14px">最后則是將swf文件顯示在網頁中,這一步需要引入多個js文件和其他文件,代碼就不寫了,直接下載,在我的上傳資料中</SPAN></P>
<P><BR>
</P>
<P><BR>
<BR>
</P>
<P><BR>
</P>

php技術將word轉化為swf 如同百度文庫般閱讀實現思路及代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 欧美黑人巨大xxxxxfreexxxxx | 日韩亚洲欧美日本精品va | 欧美成人午夜视频免看 | 午夜一级 | 国产亚洲欧美一区二区三区 | 国产拳头交一区二区 | 国产一区二区三区免费观看 | 日本精品久久久久中文字幕8 | 天天色天天干天天射 | 亚洲精品福利视频 | 最黄最色视频 | 国色天香网站 | 精品久久久中文字幕 | 国产网红在线 | 97人人超人超人国产第一页 | 可以直接看的av网址站 | 99热国产在线观看 | 成人短视频在线观看 | 手机在线观看黄色网址 | 欧美综合色区 | 一级韩国aa毛片免费观看 | 久久久久久久免费 | 成人免费午夜视频 | 免费永久在线观看污污的网站 | 自拍一区在线观看 | 国产91第一页 | 丁香视频在线观看播放 | 在线国产一区二区三区 | 中文字幕日韩精品一区口 | 久久成人免费网站 | 国产精品久久现线拍久青草 | 婷婷激情在线 | 天天在线天天综合网色 | 亚洲综合三区 | 午夜视频在线免费播放 | 成人年鲁鲁在线观看视频 | 91碰在线视频 | 天天干b| 欧美福利第一页 | 美女色影院 | 国产成品精品午夜视频 |