仿百度文库在线阅读实现

1.下载pdfTools,网址:http://www.swftools.org/download.html
1)安装pdftools并设置环境变量path;
2)转换pdf到swf的命令为:
    pdf2swf -t xxx.pdf -s flashversion=9 -o yyy.swf
3) 其他工具如下:
font2swf.exe 
gif2swf.exe 
jpeg2swf.exe 
pdf2swf.exe 
png2swf.exe 
wav2swf.exe 

2. 下载flexpaper


3. Java示例1:
1)生成swf,当然也可以使用servlet或者struts2的方式:

  1. <%  
  2. /* 
  3.  * Created on 2010-11-17 
  4.  */  
  5.  //获取文件所在目录  
  6.   String path=request.getRealPath("/");  
  7.  //使用pdf2swf转换命令  
  8.  String command= "D:/SWFTools/pdf2swf.exe  -t \""+path+"\\test.pdf\" -o  \""+path+"\\test.swf\" -s flashversion=9 ";  
  9.  //执行cmd命令  
  10.  Runtime.getRuntime().exec("cmd /c "+command);  
  11. %>  
说明: 但是注意的最好指定flashversion 为9,防止出现一些意外的错误, pdf2swf 中并不是所有的pdf都能转换,加密的pdf pdf2swf转换不了
2)Javascript代码
  1. <script type="text/javascript" src="js/swfobject/swfobject.js"></script>  
  2.  <script type="text/javascript">  
  3.          var swfVersionStr = "10.0.0";  
  4.          var xiSwfUrlStr = "playerProductInstall.swf";  
  5.          var flashvars = {  
  6.                SwfFile : escape("test.swf"),  
  7.    Scale : 0.6,  
  8.    ZoomTransition : "easeOut",  
  9.    ZoomTime : 0.5,  
  10.      ZoomInterval : 0.1,  
  11.      FitPageOnLoad : false,  
  12.      FitWidthOnLoad : true,  
  13.      PrintEnabled : true,  
  14.      FullScreenAsMaxWindow : false,  
  15.      ProgressiveLoading : true,  
  16.      PrintToolsVisible : true,  
  17.      ViewModeToolsVisible : true,  
  18.      ZoomToolsVisible : true,  
  19.      FullScreenVisible : true,  
  20.      NavToolsVisible : true,  
  21.      CursorToolsVisible : true,  
  22.    SearchToolsVisible : true,  
  23.      localeChain: "zh_CN"  
  24.    };  
  25.   
  26.  var params = {  
  27.   
  28.     }  
  29.          params.quality = "high";  
  30.          params.bgcolor = "#ffffff";  
  31.          params.allowscriptaccess = "sameDomain";  
  32.          params.allowfullscreen = "true";  
  33.          var attributes = {};  
  34.          attributes.id = "FlexPaperViewer";  
  35.          attributes.name = "FlexPaperViewer";  
  36.          swfobject.embedSWF(  
  37.              "FlexPaperViewer.swf""flashContent",  
  38.              "650""500",  
  39.              swfVersionStr, xiSwfUrlStr,  
  40.              flashvars, params, attributes);  
  41. swfobject.createCSS("#flashContent""display:block;text-align:left;");  
  42.      </script>  
  43.   
  44.  <body>  
  45.   <div style="position:absolute;left:10px;top:10px;">  
  46.       <div id="flashContent">  
  47.       </div>  
  48.      </div>  
  49. </body> 


参考资料:
1. h ttp://www.cnblogs.com/qinpeifeng107/archive/2011/08/29/2158879.html
2.  http://xianglp.iteye.com/blog/814027http://

猜你喜欢

转载自blog.csdn.net/Hibernate4Spring/article/details/7769744