一区二区久久-一区二区三区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 如同百度文庫般閱讀實現思路及代碼,轉載需保留來源!

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

主站蜘蛛池模板: 能在线观看的一区二区三区 | 91福利在线视频 | 成人国产精品视频频 | 中文字幕一区二区日产乱码 | 国产网红在线观看 | 日韩视频免费一区二区三区 | 精品久久中文字幕 | 首页 动漫 亚洲 欧美 日韩 | 2021国产成人午夜精品 | www.激情网.com | 国产91在线精品福利 | 久久宗合色 | 久久国产精品网 | 久久久久久一级毛片免费无遮挡 | 91人人看 | 99免费精品视频 | 亚洲综合天堂 | 男女一级毛片 | 亚洲热在线视频 | 亚洲欧美精品久久 | 小明日韩在线看看永久区域 | 亚洲婷婷综合色高清在线 | 麻豆久久精品免费看国产 | 美国一区二区三区 | 香蕉久久久久久狠狠色 | 久久伊人热 | 日韩中文精品亚洲第三区 | 91国内在线国内在线播放 | 色呦色呦色精品 | 亚洲一区二区三区精品影院 | 一区二区三区影视 | 美女牲交视频一级毛片 | 亚洲欧美视频一区二区三区 | 国产大片91精品免费看3 | 日本久草视频 | 亚洲人成影视 | 亚洲精品成人中文网 | 国产成人亚洲精品2020 | 天天色踪合 | 久久精品国产91久久综合麻豆自制 | 2019天天操天天干天天透 |