欢迎光临
我们一直在努力

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

 

最近有个项目需要用到类似百度文库以及豆丁的在线浏览组件,网上转悠半天就找到了个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页的加载过程,木想到好方法啊。

http://www.cnblogs.com/qiuwuyu/archive/2011/08/26/2154153.html

 
赞(0) 打赏
未经允许不得转载:刘旭的人个博客 » ASP.NET使用flexpaper做在线文档浏览
分享到: 更多 (0)
标签:

评论 抢沙发

评论前必须登录!

 

QQ :13945502电话:13913571631

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

×
订阅图标按钮