ztxkutils 2.10.66-37 → 2.10.66-38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/print.js +4 -2
- package/package.json +1 -1
package/dist/print.js
CHANGED
@@ -71,7 +71,7 @@ function getTextDimensions(text, fontSize) {
|
|
71
71
|
tempElement.style.whiteSpace = 'nowrap'; // 防止文本换行影响宽度测量
|
72
72
|
tempElement.style.fontSize = fontSize;
|
73
73
|
tempElement.style.fontFamily = '微软雅黑';
|
74
|
-
tempElement.style.padding = '
|
74
|
+
tempElement.style.padding = '50px 10px';
|
75
75
|
// 插入到body中
|
76
76
|
document.body.appendChild(tempElement);
|
77
77
|
// 获取元素的宽高
|
@@ -81,7 +81,7 @@ function getTextDimensions(text, fontSize) {
|
|
81
81
|
document.body.removeChild(tempElement);
|
82
82
|
// 返回测量结果
|
83
83
|
return {
|
84
|
-
width: width >
|
84
|
+
width: width > 520 ? 520 : width < 240 ? 240 : width,
|
85
85
|
height: height > 200 ? 200 : height < 100 ? 100 : height,
|
86
86
|
};
|
87
87
|
}
|
@@ -107,11 +107,13 @@ function createWaterHandle(obj) {
|
|
107
107
|
var canvas = document.createElement('canvas');
|
108
108
|
// 如何计算水印的大小。创建一个元素插入到body中,获取到宽高后移除
|
109
109
|
var _b = getTextDimensions(waterText, fontSize || '18px'), textWidth = _b.width, textHeight = _b.height;
|
110
|
+
// 之前的宽度是文本长度 * 22
|
110
111
|
var defaultCanvasWidth = waterText
|
111
112
|
? waterText.length > 10
|
112
113
|
? textWidth
|
113
114
|
: 240
|
114
115
|
: 240;
|
116
|
+
// 之前的高度是文本长度 * 9
|
115
117
|
var defaultCanvasHeight = waterText
|
116
118
|
? waterText.length > 10
|
117
119
|
? textHeight
|