亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    怎么實(shí)現(xiàn)php在線演示功能

    php在線演示功能的實(shí)現(xiàn)方法:1、將其他格式的文檔通過(guò)OpenOffice轉(zhuǎn)換成PDF格式文檔;2、通過(guò)swftools將PDF格式文檔轉(zhuǎn)換為swf格式文檔;3、通過(guò)flexpaper顯示swf格式的文檔,從而實(shí)現(xiàn)預(yù)覽多種格式的文檔即可。

    怎么實(shí)現(xiàn)php在線演示功能

    本文操作環(huán)境:Windows7系統(tǒng)、PHP7.1版,DELL G3電腦

    怎么實(shí)現(xiàn)php在線演示功能?

    Windows下實(shí)現(xiàn)php在線預(yù)覽功能

    最近用到文檔在線預(yù)覽功能,之前沒(méi)接觸過(guò),一切從零開(kāi)始,整了一段時(shí)間終于實(shí)現(xiàn),現(xiàn)在把方法分享給大家!

    一、主要思路

      先將其他格式的文檔(office文檔、txt、圖片等等)通過(guò)OpenOffice轉(zhuǎn)換成PDF格式文檔,然后通過(guò)swftools(http://www.swftools.org/)將PDF格式文檔轉(zhuǎn)換為swf格式文檔,最后通過(guò)flexpaper顯示swf格式的文檔,從而實(shí)現(xiàn)預(yù)覽多種格式的文檔。

      使用到的工具自己從網(wǎng)上下載,很好找的。

    二、實(shí)現(xiàn)過(guò)程

      1.其他文檔轉(zhuǎn)為PDF

       用命令啟動(dòng)OpenOffice:

          運(yùn)行->cmd,輸入下面的命令

    cd /d E:/openoffice/program & soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

          或者在cmd中進(jìn)入program目錄,然后輸入

    soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

       php實(shí)現(xiàn)代碼:     

     set_time_limit(0);                           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);                          }                         $doc_file = 'D:/wamp/www/onlineread/uploads/docfile.doc';                          $output_file = 'D:/wamp/www/onlineread/uploads/pdffile.pdf';                         $doc_file = "file:///" . $doc_file;                          $output_file = "file:///" . $output_file;                        word2pdf($doc_file,$output_file);

      2.PDF轉(zhuǎn)換為swf并顯示

       php實(shí)現(xiàn)代碼:

    <div style="width:100%;height:800px;display:block;margin-left: auto;margin-right: auto; margin-top: 20px;">          <a id="viewerPlaceHolder" style="width:100%;height:800px;display:block;"></a>            <script type="text/javascript">            var path="/<?=$convert?>";//調(diào)用php的變量,如果不能實(shí)現(xiàn)可考慮下一句的寫(xiě)法            //var path="/<?php echo $convert?>";              var fp = new FlexPaperViewer(              '__PUBLIC__/FlexPaper/FlexPaperFlash/FlexPaperViewer',              'viewerPlaceHolder', { config : {//配置參數(shù),可自行修改成自己想要的                SwfFile : escape(path),                Scale : 1,                ZoomTransition : 'easeOut',                ZoomTime : 0.5,                ZoomInterval : 0.2,                FitPageOnLoad : false,                FitWidthOnLoad : false,                PrintEnabled : true,                FullScreenAsMaxWindow : false,                ProgressiveLoading : false,                MinZoomSize : 0.2,                MaxZoomSize : 5,                SearchMatchAll : false,                InitViewMode : 'Portrait',                ViewModeToolsVisible : true,                ZoomToolsVisible : true,                NavToolsVisible : true,                CursorToolsVisible : true,                SearchToolsVisible : true,                localeChain: 'en_US'            }});          </script>        </div>

      3.運(yùn)行前的準(zhǔn)備

       需要先進(jìn)行如下的設(shè)置,否則運(yùn)行過(guò)程中可能會(huì)出錯(cuò)!

       控制面板-管理工具-組件服務(wù)-計(jì)算機(jī)-我的電腦-DOCM配置,找到OpenOffice Service Manager(Ver 1.0)右鍵屬性,按下圖所示進(jìn)行配置:

                    如下圖所示找到OpenOffice Service Manager(Ver 1.0):

    怎么實(shí)現(xiàn)php在線演示功能

                      在彈出框中選擇‘安全’,分別編輯‘啟動(dòng)和激活權(quán)限’和‘訪問(wèn)權(quán)限’:

    怎么實(shí)現(xiàn)php在線演示功能

                       在‘啟動(dòng)和激活權(quán)限’彈出框中點(diǎn)擊添加,輸入Everyone:

    怎么實(shí)現(xiàn)php在線演示功能

                      設(shè)置Everyone的權(quán)限:

    怎么實(shí)現(xiàn)php在線演示功能

                      在‘訪問(wèn)權(quán)限’的彈出框中點(diǎn)擊添加,輸入Everyone:

                    怎么實(shí)現(xiàn)php在線演示功能

                     設(shè)置Everyone權(quán)限:

    怎么實(shí)現(xiàn)php在線演示功能

                      在屬性對(duì)話框中選擇‘標(biāo)識(shí)’,選擇‘交互式用戶’:

      怎么實(shí)現(xiàn)php在線演示功能

       如果遇到COM類實(shí)例化失敗的問(wèn)題,打開(kāi)php配置文件,去掉com.allow_dcom=true前面的分號(hào),并添加extension=php_com_dotnet.dll,因?yàn)閜hp5.4以后就不內(nèi)嵌com了。

       設(shè)置好后不要忘記重啟服務(wù)哦!

       推薦學(xué)習(xí):《PHP視頻教程》

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)