onlinePreview.jsp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <%@ page contentType="text/html;charset=GBK"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <%
  4. String path = request.getContextPath();
  5. String basePath = request.getScheme() + "://"
  6. + request.getServerName() + ":" + request.getServerPort();
  7. %>
  8. <html>
  9. <head>
  10. <title>在线显示</title>
  11. <script type="text/javascript" src="/shares/js/jquery-1.9.0.min.js" ></script>
  12. <script type="text/javascript" src="/shares/js/yw/core/FlexPaper/js/flash.js"></script>
  13. <script type="text/javascript" src="/shares/js/yw/core/FlexPaper/js/flexpaper_flash.js"></script>
  14. <style type="text/css">
  15. #menu1,.l-menu-shadow {
  16. top: 30px;
  17. left: 50px;
  18. }
  19. #menu1 {
  20. width: 200px;
  21. }
  22. .div_view2{
  23. text-align:center;
  24. background-image:url(${attach.path});
  25. background-position:center;
  26. background-repeat:no-repeat;
  27. line-height:30px;
  28. overflow:hidden;
  29. }
  30. </style>
  31. <script>
  32. $(function() {
  33. var extendFlag = "${extFiles}";
  34. var html="";
  35. // if is image
  36. if(extendFlag == "jpg") {
  37. $("div.doc-view").removeClass("div_view").addClass("div_view2");
  38. }
  39. else if(extendFlag == "gif") {
  40. $("div.doc-view").removeClass("div_view").addClass("div_view2");
  41. }
  42. else if(extendFlag == "png") {
  43. $("div.doc-view").removeClass("div_view").addClass("div_view2");
  44. }
  45. // if is office or pdf file doc|docx|ppt|xls|xlsx|txt
  46. else if(extendFlag == "doc"||extendFlag == "docx"||extendFlag == "xls"||extendFlag == "xlsx"||extendFlag == "ppt"||extendFlag == "txt"||extendFlag == "jsp") {
  47. if("${attach.flashPath}"==""){
  48. html += "<div class='alert alert-info'>文档转换失败。</div>";
  49. $("div.doc-view").html(html);
  50. }else{
  51. var path="<%=basePath%>";
  52. initOnlineView(path+"${attach.flashPath}");
  53. }
  54. }
  55. else {
  56. html += "<div class='alert alert-info'>该文档不能在线浏览。</div>";
  57. $("div.doc-view").html(html);
  58. }
  59. });
  60. function initOnlineView(startDocument) {
  61. var fp = new FlexPaperViewer(
  62. '/shares/js/yw/core/FlexPaper/FlexPaperViewer',
  63. 'viewerPlaceHolder', { config : {
  64. SwfFile : escape(startDocument),
  65. MinZoomSize : 0.2,
  66. MaxZoomSize : 5,
  67. InitViewMode : 'Portrait',
  68. BitmapBasedRendering : false,
  69. PrintEnabled : false,
  70. Scale : 1,
  71. ZoomTransition : 'easeOut',
  72. ZoomTime : 0.5,
  73. ZoomInterval : 0.1,
  74. FitPageOnLoad : false,
  75. FitWidthOnLoad : false,
  76. FullScreenAsMaxWindow : false,
  77. ProgressiveLoading : false,
  78. MinZoomSize : 0.2,
  79. MaxZoomSize : 5,
  80. SearchMatchAll : false,
  81. ViewModeToolsVisible : true,
  82. ZoomToolsVisible : true,
  83. NavToolsVisible : true,
  84. CursorToolsVisible : true,
  85. SearchToolsVisible : true,
  86. localeChain: 'zh_CN'
  87. }});
  88. }
  89. </script>
  90. </head>
  91. <body>
  92. <div class="wrapper" style="width: 101.5%">
  93. <input type="hidden" name="flashPath" value="${attach.flashPath}">
  94. <div id="viewArea" class="doc-view"><a id="viewerPlaceHolder" style="width:100%;height:${h}px;display:block"></a></div>
  95. </div>
  96. </body>
  97. </html>