zoukankan      html  css  js  c++  java
  • pdf2swf+flexpaper解决pdf在线阅读(类百度文库)

    转自:http://jelly-x.iteye.com/blog/935592

    1:工具准备 
    swftools.exe 下载 
    http://www.swftools.org/download.html 
    安装至D盘 
    SWFTools提供了一系列将各种文件转成swf的工具: 
    font2swf.exe 
    gif2swf.exe 
    jpeg2swf.exe 
    pdf2swf.exe 
    png2swf.exe 
    wav2swf.exe 
    这里我们只使用pdf2swf.exe 

    flexpaper下载 
    http://code.google.com/p/flexpaper/ 
    这里我们使用已经编译好的FlexPaper的flash版本 

    2:示例语言,这里我使用的两种开发环境做示例 
       php示例 
       由pdf生成swf文件 


    Php代码

    <?php
    /*
     * Created on 2010-11-17
     *
     * To change the template for this generated file go to
     * Window - Preferences - PHPeclipse - PHP - Code Templates
     */
     //获取文件所在目录
     $dir=dirname(__FILE__) ;
     //删除测试文件
     @unlink( $dir."\\test.swf" );
     //使用pdf2swf转换命令
     $command= "D:/SWFTools/pdf2swf.exe  -t \"".$dir."\\test.pdf\" -o  \"".$dir."\\test.swf\" -s flashversion=9 ";
     //创建shell对象
     $WshShell   = new COM("WScript.Shell");
     //执行cmd命令
     $oExec      = $WshShell->Run("cmd /C ". $command, 0, true);
    ?>


    java示例 

    Java代码
    <%
    /*
     * Created on 2010-11-17
     */
     //获取文件所在目录
      String path=request.getRealPath("/");
     //使用pdf2swf转换命令
     String command= "D:/SWFTools/pdf2swf.exe  -t \""+path+"\\test.pdf\" -o  \""+path+"\\test.swf\" -s flashversion=9 ";
     //执行cmd命令
     Runtime.getRuntime().exec("cmd /c "+command);
    %>
     
    
       以上是php,java将pdf转换成swf方式,那显示呢,这样我们会使用到flexpaper,一下是flexpaper的使用
       使用flexpaper展现swf
    
       <script type="text/javascript" src="js/swfobject/swfobject.js"></script>
        <script type="text/javascript">
                var swfVersionStr = "10.0.0";
                var xiSwfUrlStr = "playerProductInstall.swf";
                var flashvars = {
                      SwfFile : escape("test.swf"),
          Scale : 0.6,
          ZoomTransition : "easeOut",
          ZoomTime : 0.5,
            ZoomInterval : 0.1,
            FitPageOnLoad : false,
            FitWidthOnLoad : true,
            PrintEnabled : true,
            FullScreenAsMaxWindow : false,
            ProgressiveLoading : true,
            PrintToolsVisible : true,
            ViewModeToolsVisible : true,
            ZoomToolsVisible : true,
            FullScreenVisible : true,
            NavToolsVisible : true,
            CursorToolsVisible : true,
          SearchToolsVisible : true,
            localeChain: "zh_CN"
          };
    
        var params = {
    
           }
                params.quality = "high";
                params.bgcolor = "#ffffff";
                params.allowscriptaccess = "sameDomain";
                params.allowfullscreen = "true";
                var attributes = {};
                attributes.id = "FlexPaperViewer";
                attributes.name = "FlexPaperViewer";
                swfobject.embedSWF(
                    "FlexPaperViewer.swf", "flashContent",
                    "650", "500",
                    swfVersionStr, xiSwfUrlStr,
                    flashvars, params, attributes);
       swfobject.createCSS("#flashContent", "display:block;text-align:left;");
            </script>
      
        <body>
         <div style="position:absolute;left:10px;top:10px;">
             <div id="flashContent">
             </div>
            </div>
       </body>
  • 相关阅读:
    android调用系统拍照那些事
    HttpClient4.5
    关于Android自带的定位处理
    ORMLite配置异常处理
    mysql绿色版配置
    android 震动和提示音
    Weblogic新增域(可以配置新端口)
    weblogic启动错误
    将程序部署到weblogic出现乱码问题
    SVN更新报错
  • 原文地址:https://www.cnblogs.com/qlong8807/p/2869171.html
Copyright © 2011-2022 走看看