在线预览文件(pdf)

1.flash版(借助flexpaper工具)

可以把pdf文件用pdf2swf工具转换成swf文件。下载地址http://www.swftools.org/download.html

转换代码如下:

 1     public void PDFConvertToSWF(string sourcePath, string targetPath)

 2     {

 3         Process p = new Process();

 4         p.StartInfo.FileName = "cmd.exe";

 5         p.StartInfo.WorkingDirectory = "C:\\WINDOWS\\system32";

 6         p.StartInfo.UseShellExecute = false;

 7         p.StartInfo.RedirectStandardInput = true;

 8         p.StartInfo.RedirectStandardOutput = true;

 9         p.StartInfo.RedirectStandardError = true;

10         p.StartInfo.CreateNoWindow = true;

11         p.Start();

12         //如果碰到语言问题可用这行代码

13         //string cmd = "C:/pdf2swf.exe" + " " + sourcePath + " -o " + targetPath + " C:/xpdf/chinese-simplified";

14         //如果碰到版本问题可用这行代码

15         string cmd = "C:/pdf2swf.exe" + " " + sourcePath + "  -s flashversion=9 -o " + targetPath;

16         p.StandardInput.WriteLine(cmd);

17         p.StandardInput.WriteLine("exit");

18         p.Close();

19     }    
转换方法

转换成flash之后可以用flexpaper预览。下载地址http://code.google.com/p/flexpaper/downloads/list
在网页中依次引入:jquery.min.js,flexpaper.js,flexpaper_handlers.js。同时要注意FlexPaperViewer.swf文件的位置

然后就是配置:

 1 <script type="text/javascript">

 2         $('#documentViewer').FlexPaperViewer(

 3             {

 4                 config: {

 5 

 6                     SWFFile: '/upload/123.swf',

 7 

 8                     Scale: 0.6,

 9                     ZoomTransition: 'easeOut',

10                     ZoomTime: 0.5,

11                     ZoomInterval: 0.2,

12                     FitPageOnLoad: true,

13                     FitWidthOnLoad: false,

14                     FullScreenAsMaxWindow: false,

15                     ProgressiveLoading: false,

16                     MinZoomSize: 0.2,

17                     MaxZoomSize: 5,

18                     SearchMatchAll: false,

19                     InitViewMode: 'Portrait',

20                     RenderingOrder: 'flash',

21                     StartAtPage: '',

22                     ViewModeToolsVisible: true,

23                     ZoomToolsVisible: true,

24                     NavToolsVisible: true,

25                     CursorToolsVisible: true,

26                     SearchToolsVisible: true,

27                     WMode: 'window',

28                     localeChain: 'zh_CN',

29                     jsDirectory: "/js/"

30                 }

31             }

32     );

33 </script>
配置代码

 

 

 

你可能感兴趣的:(pdf)