• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

[转]ASP.NET使用flexpaper做在线文档浏览

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文转自: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页的加载过程,木想到好方法啊。

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
中文VS2008安装ASP.NETMVC框架问题(没有MVC模板)发布时间:2022-07-10
下一篇:
ASP.NET4.0安裝在IIS6最常遇到的四個問題发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap