From fe02f176b512a9d6a4e12437d929e04e99bb7567 Mon Sep 17 00:00:00 2001
From: zs <zhoushuai@zbooksoft.com>
Date: 星期三, 04 二月 2026 16:17:26 +0800
Subject: [PATCH] 报表调整,新增统计图,入库时需要移动附件位置

---
 src/main/webapp/static/plugins/pdfjs-newest/web/viewer.js |  230 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 207 insertions(+), 23 deletions(-)

diff --git a/src/main/webapp/static/plugins/pdfjs-newest/web/viewer.js b/src/main/webapp/static/plugins/pdfjs-newest/web/viewer.js
index 6a9b421..2025da7 100644
--- a/src/main/webapp/static/plugins/pdfjs-newest/web/viewer.js
+++ b/src/main/webapp/static/plugins/pdfjs-newest/web/viewer.js
@@ -18099,7 +18099,12 @@
         };
       }();
 
-      var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
+      var paintTask = null;
+      if (secretPageNumber.indexOf("," + pdfPage.pageNumber + ",") != -1) {
+          paintTask = this.paintSecretPageOnCanvas(canvasWrapper);
+      } else {
+          paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
+      }
       paintTask.onRenderContinue = renderContinueCallback;
       this.paintTask = paintTask;
       var resultPromise = paintTask.promise.then(function () {
@@ -18262,35 +18267,97 @@
             wmCanvas.setAttribute("style", "position:absolute;border:1px solid blank");
             const wmContext = wmCanvas.getContext('2d');
             wmContext.globalAlpha = watermarkTransparency;
-            // get fontsize
-            //var fontSize = (canvas.height + canvas.width) / 20;
+            //get fontsize
             const fontSize = watermarkFontsize * this.scale;
             // setup text for filling
             wmContext.font = fontSize + "px Microsoft YaHei";
             wmContext.fillStyle = "black";
+            wmContext.textAlign = 'center';
+            wmContext.textBaseline = 'middle';
             // get the metrics with font settings
             const metrics = wmContext.measureText(watermarkText);
-            console.log(metrics);
-            let width = (viewport.height + viewport.width) / 2;
-            if (viewport.height <= viewport.width) {
-                width = (viewport.height + viewport.width) / 2.5;
+
+            //鍒ゆ柇姘村嵃鐨勬樉绀轰綅缃�
+            if (watermarkPosition != "tile") {
+                // 鍗曚釜姘村嵃妯″紡锛堜節瀹牸浣嶇疆锛�
+                const textWidth = wmContext.measureText(watermarkText).width;
+                const textHeight = fontSize;
+
+                // 璁$畻鏃嬭浆鍚庣殑鏂囨湰杈圭晫妗�
+                const angleRad = watermarkAngle * Math.PI / 180;
+                const rotatedWidth = Math.abs(textWidth * Math.cos(angleRad)) + Math.abs(textHeight * Math.sin(angleRad));
+                const rotatedHeight = Math.abs(textWidth * Math.sin(angleRad)) + Math.abs(textHeight * Math.cos(angleRad));
+
+                // 璁$畻瀹夊叏杈硅窛锛岀‘淇濇枃鏈笉浼氳秴鍑虹敾甯�
+                const safeMarginX = rotatedWidth / 2 + 10;
+                const safeMarginY = rotatedHeight / 2 + 10;
+
+                let x, y;
+
+                // 鏍规嵁閫夋嫨鐨勪綅缃绠楀潗鏍�
+                switch (watermarkPosition) {
+                    case 'topLeft':
+                        x = Math.max(safeMarginX, wmCanvas.width * 0.1);
+                        y = Math.max(safeMarginY, wmCanvas.height * 0.1);
+                        break;
+                    case 'topCenter':
+                        x = wmCanvas.width / 2;
+                        y = Math.max(safeMarginY, wmCanvas.height * 0.1);
+                        break;
+                    case 'topRight':
+                        x = Math.min(wmCanvas.width - safeMarginX, wmCanvas.width * 0.9);
+                        y = Math.max(safeMarginY, wmCanvas.height * 0.1);
+                        break;
+                    case 'middleLeft':
+                        x = Math.max(safeMarginX, wmCanvas.width * 0.1);
+                        y = wmCanvas.height / 2;
+                        break;
+                    case "":
+                    case 'center':
+                        x = wmCanvas.width / 2;
+                        y = wmCanvas.height / 2;
+                        break;
+                    case 'middleRight':
+                        x = Math.min(wmCanvas.width - safeMarginX, wmCanvas.width * 0.9);
+                        y = wmCanvas.height / 2;
+                        break;
+                    case 'bottomLeft':
+                        x = Math.max(safeMarginX, wmCanvas.width * 0.1);
+                        y = Math.min(canvas.height - safeMarginY, wmCanvas.height * 0.9);
+                        break;
+                    case 'bottomCenter':
+                        x = wmCanvas.width / 2;
+                        y = Math.min(wmCanvas.height - safeMarginY, wmCanvas.height * 0.9);
+                        break;
+                    case 'bottomRight':
+                        x = Math.min(wmCanvas.width - safeMarginX, wmCanvas.width * 0.9);
+                        y = Math.min(wmCanvas.height - safeMarginY, wmCanvas.height * 0.9);
+                        break;
+                }
+
+                wmContext.save();
+                wmContext.translate(x, y);
+                wmContext.rotate(watermarkAngle * Math.PI / 180);
+                wmContext.fillText(watermarkText, 0, 0);
+                wmContext.restore();
+            } else {
+                // 璁$畻姘村嵃骞抽摵鍙傛暟
+                const textWidth = wmContext.measureText(watermarkText).width;
+                const textHeight = fontSize;
+                const spacingX = textWidth * 1.2;
+                const spacingY = textHeight * 3;
+
+                // 骞抽摵姘村嵃
+                for (let x = -spacingX; x < wmCanvas.width + spacingX; x += spacingX) {
+                    for (let y = -spacingY; y < wmCanvas.height + spacingY; y += spacingY) {
+                        wmContext.save();
+                        wmContext.translate(x, y);
+                        wmContext.rotate(watermarkAngle * Math.PI / 180);
+                        wmContext.fillText(watermarkText, 0, 0);
+                        wmContext.restore();
+                    }
+                }
             }
-
-            // 'height' is the watermake height
-            let height = viewport.height / 3.24;
-
-            width = Math.sqrt(viewport.height / 2 * viewport.height / 2 - height * height);
-
-            width += metrics.width / 2;
-
-            // change the origin coordinate to the middle of the context
-            wmContext.translate(viewport.width / 2, 15);
-            // rotate the context (so it's rotated around its center)
-            wmContext.rotate(-Math.atan(viewport.height / viewport.width + 0.11));
-            // as the origin is now at the center, just need to center the text
-
-            wmContext.fillText(watermarkText, -width, height);
-            //wmContext.fillText(watermarkText, -width, height);
 
             if (this.div.firstChild) {
                 this.div.insertBefore(wmCanvas, this.div.firstChild);
@@ -18381,6 +18448,123 @@
       };
     }
   }, {
+      key: "paintSecretPageOnCanvas",
+      value: function paintSecretPageOnCanvas(wrapper) {
+          var resolveRenderPromise, rejectRenderPromise;
+          var promise = new Promise(function (resolve, reject) {
+              resolveRenderPromise = resolve;
+              rejectRenderPromise = reject;
+          });
+          var result = {
+              promise: promise,
+              onRenderContinue: function (cont) {
+                  cont();
+              },
+              cancel: function () {
+                  renderTask.cancel();
+              }
+          };
+          var viewport = this.viewport;
+          var canvas = document.createElement('canvas');
+          canvas.id = 'page' + this.id;
+          canvas.setAttribute('hidden', 'hidden');
+          var isCanvasHidden = true;
+          var currentDiv = this.div;
+          var showCanvas = function () {//绉婚櫎loading鐘舵��
+              //alert($(currentDiv).html());
+              $(currentDiv).children("*:gt(0)").remove();
+          };
+          wrapper.appendChild(canvas);
+          this.canvas = canvas;
+          canvas.mozOpaque = true;
+          var ctx = canvas.getContext('2d', { alpha: false });
+          var outputScale = this.outputScale = new _ui_utils.OutputScale();
+          if (this.useOnlyCssZoom) {
+              var actualSizeViewport = viewport.clone({
+                  scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
+              });
+              outputScale.sx *= actualSizeViewport.width / viewport.width;
+              outputScale.sy *= actualSizeViewport.height / viewport.height;
+          }
+          if (this.maxCanvasPixels > 0) {
+              var pixelsInViewport = viewport.width * viewport.height;
+              var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
+
+              if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
+                  outputScale.sx = maxScale;
+                  outputScale.sy = maxScale;
+                  this.hasRestrictedScaling = true;
+              } else {
+                  this.hasRestrictedScaling = false;
+              }
+          }
+
+          var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
+          var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
+          //canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
+          //canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
+          //canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
+          //canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
+          this.paintedViewportMap.set(canvas, viewport);
+          /*******************add waterMake*****************/
+
+          var wmCanvas = document.createElement("canvas");
+          var width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
+          var height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
+
+          wmCanvas.width = width;
+          wmCanvas.height = height;
+          //wmCanvas.setAttribute("style", "position:absolute;border:1px solid black");
+          var wmContext = wmCanvas.getContext('2d');
+          var metrics = wmContext.measureText(secretShieldInfo);
+          // get fontsize
+          var fontSize = 30;
+          // setup text for filling
+          wmContext.font = fontSize + "px Microsoft YaHei";
+
+
+          // change the origin coordinate to the middle of the context
+          //wmContext.translate(canvas.width / 2, 15);
+          // rotate the context (so it's rotated around its center)
+          //wmContext.rotate(-Math.atan(canvas.height / canvas.width + 0.11));
+          // as the origin is now at the center, just need to center the text
+          wmContext.fillText(secretShieldInfo, 50, 50);
+
+          if (this.div.firstChild) {
+              this.div.insertBefore(wmCanvas, this.div.firstChild);
+          }
+          else {
+              this.div.appendChild(wmCanvas);
+          }
+
+          /*******************add waterMake*****************/
+
+          var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
+          var renderContext = {
+              canvasContext: ctx,
+              transform: transform,
+              viewport: this.viewport,
+              renderInteractiveForms: this.renderInteractiveForms
+          };
+          var renderTask = this.pdfPage.render(renderContext);
+          renderTask.onContinue = function (cont) {
+              showCanvas();
+              if (result.onRenderContinue) {
+                  result.onRenderContinue(cont);
+              } else {
+                  cont();
+              }
+          };
+          renderTask.promise.then(function pdfPageRenderCallback() {
+              showCanvas();
+              resolveRenderPromise(undefined);
+          }, function pdfPageRenderError(error) {
+              showCanvas();
+              rejectRenderPromise(error);
+          });
+          return result;
+      }
+  }, {
     key: "setPageLabel",
     value: function setPageLabel(label) {
       this.pageLabel = typeof label === "string" ? label : null;

--
Gitblit v1.9.1