准备:
flexpaper,从这里下载http://code.google.com/p/flexpaper/downloads/list 或者官网http://flexpaper.devaldi.com/download/
SWFTools,从这里下载http://www.swftools.org/download.html 下载并安装
上图显示当前项目的解决方案
首先把PDF转换成SWF需要用命令行操作pdf2swf.exe (前提是安装了SWFTools,我的安装路径为E:\\Program Files (x86)\\SWFTools\\pdf2swf.exe) 我是把PDF的处理作成单独类
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Diagnostics; /// <summary> ///PDF2SWF 的摘要说明 /// </summary> public class PDF2SWF { public PDF2SWF() { // //TODO: 在此处添加构造函数逻辑 // } public static void ExecutCmd(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是输出文件的具体路径)
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class SWFShow : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string cmdStr = "E:\\Program Files (x86)\\SWFTools\\pdf2swf.exe"; //string cmdStr = HttpContext.Current.Server.MapPath("E:\\Program Files (x86)\\SWFTools\\pdf2swf.exe"); string savePath = HttpContext.Current.Server.MapPath("Test"); string filePath = HttpContext.Current.Server.MapPath("PDF/MYTEST.pdf"); string args = " -t "+filePath+" -o "+savePath+"\\MYTEST.swf"; PDF2SWF.ExecutCmd(cmdStr, args); } }
这里先要建立两个文件夹(Test,PDF)
接下来是前台显示代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SWFShow.aspx.cs" Inherits="SWFShow" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" language="javascript" src="Scripts/FlexPaperFlash_js/jquery.js"></script> <script type="text/javascript" language="javascript" src="Scripts/FlexPaperFlash_js/flexpaper_flash_debug.js"></script> </head> <body> <form id="form1" runat="server"> <div style="position:absolute;left:10px;top:10px;"> <a id="viewerPlaceHolder" style="660px;height:480px;display:block"></a> <h1>使用静态SWF实现</h1> <script type="text/javascript"> var fp = new FlexPaperViewer( ///FlexPaper组件的SWF框架路径 'Scripts/FlexPaperFlash_js/FlexPaperViewer', 'viewerPlaceHolder', { config: { ///需要显示的.swf SwfFile: 'Test/MYTEST.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> </form> </body> </html>
注意:这里用到的FlexPaperFlash_js/jquery.js,flexpaper_flash_debug.js,'Scripts/FlexPaperFlash_js/FlexPaperViewer'中的FlexPaperViewer.swf 可以在百度中输入FlexPaper_1.4.5_flash.zip下载
显示效果如下:
这个FlexPaper还在学习中,求共同学习(上面的只是简单的用法)