readOffice.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
  3. xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
  4. <head>
  5. <title>在线查看文件</title>
  6. <script src="/api/jquery.min.js"></script>
  7. <script type="text/javascript">
  8. //打印
  9. function printWord(){
  10. $.ajax({
  11. url: "print.do",
  12. dataType: "json",
  13. type: "post",
  14. data: document.getElementById("printInfo").value,
  15. success: function(result) {
  16. $("#a1").attr('disabled',true);
  17. document.getElementById("PageOfficeCtrl1").PrintOut();
  18. },
  19. error: function(data) {
  20. alert("请求出错");
  21. }
  22. });
  23. }
  24. function AfterDocumentOpened() {
  25. document.getElementById("PageOfficeCtrl1").SaveAsReadOnly = true;
  26. document.getElementById("PageOfficeCtrl1").SetEnableFileCommand(3, false); // 禁止保存
  27. document.getElementById("PageOfficeCtrl1").SetEnableFileCommand(4, true); // 禁止另存
  28. document.getElementById("PageOfficeCtrl1").SetEnableFileCommand(5, true); //禁止打印
  29. document.getElementById("PageOfficeCtrl1").SetEnableFileCommand(6, true); // 禁止页面设置
  30. document.getElementById("PageOfficeCtrl1").SetEnableFileCommand(7, false); // 禁止属性
  31. document.getElementById("PageOfficeCtrl1").SetEnableFileCommand(8, true); // 禁止打印预览
  32. }
  33. function AfterDocumentOpenedPdf() {
  34. SetPageWidth();
  35. }
  36. function SetBookmarks() {
  37. document.getElementById("PageOfficeCtrl1").BookmarksVisible = !document.getElementById("PageOfficeCtrl1").BookmarksVisible;
  38. }
  39. function Print() {
  40. document.getElementById("PageOfficeCtrl1").ShowDialog(4);
  41. }
  42. function SwitchFullScreen() {
  43. document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen;
  44. }
  45. function SetPageReal() {
  46. document.getElementById("PageOfficeCtrl1").SetPageFit(1);
  47. }
  48. function SetPageFit() {
  49. document.getElementById("PageOfficeCtrl1").SetPageFit(2);
  50. }
  51. function SetPageWidth() {
  52. document.getElementById("PageOfficeCtrl1").SetPageFit(3);
  53. }
  54. function ZoomIn() {
  55. document.getElementById("PageOfficeCtrl1").ZoomIn();
  56. }
  57. function ZoomOut() {
  58. document.getElementById("PageOfficeCtrl1").ZoomOut();
  59. }
  60. function FirstPage() {
  61. document.getElementById("PageOfficeCtrl1").GoToFirstPage();
  62. }
  63. function PreviousPage() {
  64. document.getElementById("PageOfficeCtrl1").GoToPreviousPage();
  65. }
  66. function NextPage() {
  67. document.getElementById("PageOfficeCtrl1").GoToNextPage();
  68. }
  69. function LastPage() {
  70. document.getElementById("PageOfficeCtrl1").GoToLastPage();
  71. }
  72. function RotateRight() {
  73. document.getElementById("PageOfficeCtrl1").RotateRight();
  74. }
  75. function RotateLeft() {
  76. document.getElementById("PageOfficeCtrl1").RotateLeft();
  77. }
  78. function Save() {
  79. document.getElementById("PageOfficeCtrl1").WebSave();
  80. }
  81. //文档关闭前先提示用户是否保存
  82. function BeforeBrowserClosed() {
  83. if (document.getElementById("PageOfficeCtrl1").IsDirty) {
  84. if (confirm("提示:文档已被修改,是否继续关闭放弃保存 ?")) {
  85. return true;
  86. } else {
  87. return false;
  88. }
  89. }
  90. }
  91. </script>
  92. </head>
  93. <body>
  94. <div style="width:auto;height:700px;" th:utext="${pageoffice}"></div>
  95. <input id="printInfo" name="printInfo" type="hidden" th:value="${printInfo}">
  96. <footer style="margin:auto;" th:if="${printInfo !=null && printInfo !='' }">
  97. <div style="width:100px;margin-left:auto;margin-right:auto;">
  98. <button style="width:80px;height:40px" id="a1" onclick="printWord()">打印</button>
  99. </div>
  100. </footer>
  101. </body>
  102. </html>