From fc0cc9fff4b4cbdc7cbb52b4a96c947530fcbba0 Mon Sep 17 00:00:00 2001
From: zhai <1528081232@qq.com>
Date: 星期六, 13 十二月 2025 11:04:03 +0800
Subject: [PATCH] 广海地质资料系统部分内容修改
---
src/main/webapp/static/plugins/pdfjs/web/viewer.js | 119 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 93 insertions(+), 26 deletions(-)
diff --git a/src/main/webapp/static/plugins/pdfjs/web/viewer.js b/src/main/webapp/static/plugins/pdfjs/web/viewer.js
index cbb334b..d26bc55 100644
--- a/src/main/webapp/static/plugins/pdfjs/web/viewer.js
+++ b/src/main/webapp/static/plugins/pdfjs/web/viewer.js
@@ -1863,6 +1863,10 @@
if (!this.pdfViewer.currentScaleValue) {
this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
}
+
+ if(initComplate instanceof Function){
+ initComplate();
+ }
},
cleanup: function cleanup() {
if (!this.pdfDocument) {
@@ -12722,41 +12726,104 @@
/******************add waterMake******************/
if (enableWatermark) {
- var wmCanvas = document.createElement("canvas");
+ const wmCanvas = document.createElement("canvas");
wmCanvas.width = viewport.width;
wmCanvas.height = viewport.height;
+
wmCanvas.setAttribute("style", "position:absolute;border:1px solid blank");
- var wmContext = wmCanvas.getContext('2d');
+ const wmContext = wmCanvas.getContext('2d');
wmContext.globalAlpha = watermarkTransparency;
- // get fontsize
- //var fontSize = (canvas.height + canvas.width) / 20;
- var fontSize = watermarkFontsize * this.scale;
+ //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
- var metrics = wmContext.measureText(watermarkText);
- console.log(metrics);
- var width = (canvas.height + canvas.width) / 2;
- if (viewport.height <= viewport.width) {
- width = (viewport.height + viewport.width) / 2.5;
+ const metrics = wmContext.measureText(watermarkText);
+
+ //鍒ゆ柇姘村嵃鐨勬樉绀轰綅缃�
+ 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
- var 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);
--
Gitblit v1.9.1