zoukankan      html  css  js  c++  java
  • [转]ASP.NET使用flexpaper做在线文档浏览

    本文转自:http://www.cnblogs.com/qiuwuyu/archive/2011/08/26/2154153.html

    最近有个项目需要用到类似百度文库以及豆丁的在线浏览组件,网上转悠半天就找到了个flexpaper,需要从这里下载http://code.google.com/p/flexpaper/downloads/list flexpaper 支持的文档类型为swf格式。于是乎,就想着把pdf文件转换成swf,因为装了adobe reader软件的电脑ms word之类的文档可以直接保存为pdf格式。网上都说pdf2swf这个工具不错,需要从这里下载http://www.swftools.org/download.html 。只需要用命令行操作即可,小试一下果然牛的不得了啊。

    PDF转换成SWF需要用命令行操作pdf2swf.exe,代码如下

            public static void ExecuteCmd(string cmd,string args)

            {

                using (Process p = new Process())

                {

                    p.StartInfo.FileName = cmd;

                    p.StartInfo.Arguments = args;

                    p.StartInfo.UseShellExecute = false;

                    p.StartInfo.RedirectStandardOutput = false;

                    p.StartInfo.CreateNoWindow = true;

                    p.Start();

                    p.PriorityClass = ProcessPriorityClass.Normal;

                    p.WaitForExit();

                }

            }

    调用代码如下,给pdf2swf.exe所传的参数简单说描述下,-t后面跟的就是目标文件路径,-o是输出文件的具体路径,

                string cmdStr = HttpContext.Current.Server.MapPath("FlexPaper/pdf2swf.exe");

                string savePath = HttpContext.Current.Server.MapPath("Test");

                string filePath = HttpContext.Current.Server.MapPath("PDF/Amazon隐藏的帝国.pdf");

                string args = " -t " + filePath + " -o " + savePath + "\\Amazon隐藏的帝国.swf";

                //分页

                //string args = " -t " + filePath + " -o " + savePath + "\\Amazon隐藏的帝国%.swf -f -T 9 -t -s storeallcharacters";

                PDF2SWFCmd.ExecuteCmd(cmdStr, args);

    前台展示文档页面代码如下,都是从官网demo直接粘贴的,呵呵

        <script language="javascript" type="text/javascript" src="FlexPaper/js/jquery.js"></script>

        <script language="javascript" type="text/javascript" src="FlexPaper/js/flexpaper_flash_debug.js"></script>

        <div style="position:absolute;left:10px;top:10px;">

                     <a id="viewerPlaceHolder" style="width:660px;height:480px;display:block"></a>

                     <script type="text/javascript">

                         var fp = new FlexPaperViewer(

                                                             'FlexPaper/FlexPaperViewer',

                                                             'viewerPlaceHolder', { config: {

                                                                 SwfFile: 'Test/Amazon隐藏的帝国.swf',

                                                                 Scale: 0.6,

                                                                 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>

    一切操作正常后的运行界面应该类似如下界面,

    如果打开页面后想定位到某一页,需要修改配置文件

    ProgressiveLoading: true

    而后调用api接口,假如想跳到第10页,可以这样写

     function onDocumentLoaded(totalPages) {

                    getDocViewer().gotoPage(10);

                }

    但是这种方法可以明显看到从第一页转到第10页的加载过程,木想到好方法啊。

  • 相关阅读:
    [USACO09Open] Tower of Hay 干草塔
    [HNOI2004]打鼹鼠
    BZOJ1222[HNOI 2001]产品加工
    BZOJ1270[BJWC2008]雷涛的小猫
    NOIP2018出征策
    解析·NOIP·冷门 CLZ最小环
    CCF-NOIP-2018 提高组(复赛) 模拟试题(九)(2018 CSYZ长沙一中)
    [脚本无敌1]图片批量处理(matlab)
    用Matlab解《2013年数据建模比赛》图像碎片拼接题
    火灾检测-fire,fire
  • 原文地址:https://www.cnblogs.com/freeliver54/p/2427132.html
Copyright © 2011-2022 走看看