溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

將word轉(zhuǎn)化為swf 如同百度文庫般閱讀實(shí)現(xiàn)思路及代碼

發(fā)布時(shí)間:2021-10-11 22:40:10 來源:億速云 閱讀:94 作者:iii 欄目:開發(fā)技術(shù)

本篇內(nèi)容介紹了“將word轉(zhuǎn)化為swf 如同百度文庫般閱讀實(shí)現(xiàn)思路及代碼”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

復(fù)制代碼 代碼如下:

<SPAN >實(shí)現(xiàn)如同百度文庫那樣類似功能需要進(jìn)行一系列轉(zhuǎn)化,一般流程想將word轉(zhuǎn)化為pdf格式,再將pdf格式轉(zhuǎn)化為swf格式。在網(wǎng)頁上顯示其實(shí)都是swf格式內(nèi)容。</SPAN>


首先將word轉(zhuǎn)化為swf,需要調(diào)用com組件,可以通過office 或者wps進(jìn)行轉(zhuǎn)化,但我嘗試都沒有成功,最后通過OpenOffice 4.0.0 進(jìn)行轉(zhuǎn)化才成功,OpenOffice 4.0.0支持windows 和linux操作系統(tǒng),故需要先下載openOffice,官網(wǎng)上應(yīng)該有。將word轉(zhuǎn)化為pdf,好像只是支持英文的標(biāo)題的文檔,不支持漢文名字文檔,可以先將文件重新命名為英文,轉(zhuǎn)化之后再將文件變?yōu)闈h文即可,可能還需要開始o(jì)penoffice 服務(wù),上圖
將word轉(zhuǎn)化為swf 如同百度文庫般閱讀實(shí)現(xiàn)思路及代碼 
驗(yàn)證服務(wù)是否開啟,上圖
將word轉(zhuǎn)化為swf 如同百度文庫般閱讀實(shí)現(xiàn)思路及代碼 
代碼如下:

復(fù)制代碼 代碼如下:


<PRE class=php name="code"><?php
class RunTime//頁面執(zhí)行時(shí)間類
{
private $starttime;//頁面開始執(zhí)行時(shí)間
private $stoptime;//頁面結(jié)束執(zhí)行時(shí)間
private $spendtime;//頁面執(zhí)行花費(fèi)時(shí)間
function getmicrotime()//獲取返回當(dāng)前微秒數(shù)的浮點(diǎn)數(shù)
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()//頁面開始執(zhí)行函數(shù),返回開始頁面執(zhí)行的時(shí)間
{
$this->starttime=$this->getmicrotime();
}
function end()//顯示頁面執(zhí)行的時(shí)間
{
$this->stoptime=$this->getmicrotime();
$this->spendtime=$this->stoptime-$this->starttime;
//return round($this->spendtime,10);
}
function display()
{
//$this->end();
echo "<p>運(yùn)行時(shí)間:".round($this->spendtime,10)."秒</p>";
}
}
/*調(diào)用方法 */
$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>
花費(fèi)時(shí)間進(jìn)行分析:
<P>將一個(gè)大小為1.48M的word文檔轉(zhuǎn)化為pdf需要<SPAN >運(yùn)行時(shí)間:1.3652579784秒</SPAN>&nbsp;自己電腦是這個(gè)時(shí)間,自己測試</P>
<P><BR>
</P>
<P>其次將pdf轉(zhuǎn)化為swf,需要運(yùn)用另外一個(gè)軟件,swftools &nbsp;通過代碼調(diào)用cmd命令,直接上代碼</P>
<P><PRE class=php name="code"><?php
class RunTime//頁面執(zhí)行時(shí)間類
{
private $starttime;//頁面開始執(zhí)行時(shí)間
private $stoptime;//頁面結(jié)束執(zhí)行時(shí)間
private $spendtime;//頁面執(zhí)行花費(fèi)時(shí)間
function getmicrotime()//獲取返回當(dāng)前微秒數(shù)的浮點(diǎn)數(shù)
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()//頁面開始執(zhí)行函數(shù),返回開始頁面執(zhí)行的時(shí)間
{
$this->starttime=$this->getmicrotime();
}
function end()//顯示頁面執(zhí)行的時(shí)間
{
$this->stoptime=$this->getmicrotime();
$this->spendtime=$this->stoptime-$this->starttime;
//return round($this->spendtime,10);
}
function display()
{
//$this->end();
echo "<p>運(yùn)行時(shí)間:".round($this->spendtime,10)."秒</p>";
}
}
/*調(diào)用方法 */
$timer=new Runtime();
$timer->start();


//調(diào)用系統(tǒng)軟件
$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>
將剛才轉(zhuǎn)化而來的pdf轉(zhuǎn)化為swf文件需要用<SPAN >運(yùn)行時(shí)間:1.3119211197秒時(shí)間</SPAN><P></P>
<P><SPAN >最后則是將swf文件顯示在網(wǎng)頁中,這一步需要引入多個(gè)js文件和其他文件,代碼就不寫了,直接下載,在我的上傳資料中</SPAN></P>
<P><BR>
</P>
<P><BR>
<BR>
</P>
<P><BR>
</P>

“將word轉(zhuǎn)化為swf 如同百度文庫般閱讀實(shí)現(xiàn)思路及代碼”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI