pdf.ftl 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
  6. <title>PDF预览</title>
  7. <#include "*/commonHeader.ftl">
  8. <script src="js/base64.min.js" type="text/javascript"></script>
  9. </head>
  10. <body>
  11. <#if pdfUrl?contains("http://") || pdfUrl?contains("https://")>
  12. <#assign finalUrl="${pdfUrl}">
  13. <#else>
  14. <#assign finalUrl="${baseUrl}${pdfUrl}">
  15. </#if>
  16. <iframe src="" width="100%" frameborder="0"></iframe>
  17. <#if "false" == switchDisabled>
  18. <img src="images/jpg.svg" width="48" height="48" style="position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>
  19. </#if>
  20. </body>
  21. <script type="text/javascript">
  22. var url = '${finalUrl}';
  23. var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
  24. if (!url.startsWith(baseUrl)) {
  25. url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
  26. }
  27. document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disablepresentationmode=${pdfPresentationModeDisable}&disableopenfile=${pdfOpenFileDisable}&disableprint=${pdfPrintDisable}&disabledownload=${pdfDownloadDisable}&disablebookmark=${pdfBookmarkDisable}&disableediting=${pdfDisableEditing}";
  28. document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
  29. /**
  30. * 页面变化调整高度
  31. */
  32. window.onresize = function () {
  33. var fm = document.getElementsByTagName("iframe")[0];
  34. fm.height = window.document.documentElement.clientHeight - 10;
  35. }
  36. function goForImage() {
  37. var url = window.location.href
  38. if (url.indexOf("tifPreviewType=pdf") != -1) {
  39. url = url.replace("tifPreviewType=pdf", "tifPreviewType=jpg");
  40. } else {
  41. url = url + "&tifPreviewType=jpg";
  42. }
  43. if (url.indexOf("officePreviewType=pdf") != -1) {
  44. url = url.replace("officePreviewType=pdf", "officePreviewType=image");
  45. } else {
  46. url = url + "&officePreviewType=image";
  47. }
  48. window.location.href = url;
  49. }
  50. /*初始化水印*/
  51. window.onload = function () {
  52. initWaterMark();
  53. }
  54. </script>
  55. </html>