ztxkutils 2.10.27 → 2.10.28
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/index.js +1 -1
- package/dist/print.d.ts +4 -2
- package/dist/print.js +39 -15
- package/dist/request-944adae3.js +2838 -0
- package/dist/request-bf005f3d.js +2834 -0
- package/dist/request.d.ts +3 -1
- package/dist/request.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -2,7 +2,7 @@ export { c as authority } from './authority-e6bde99f.js';
|
|
2
2
|
export { d as dataModel } from './dataModel-1fbaff40.js';
|
3
3
|
export { t as tools } from './tools-09a4d620.js';
|
4
4
|
export { v as validate } from './validate-6e735536.js';
|
5
|
-
export { r as request } from './request-
|
5
|
+
export { r as request } from './request-944adae3.js';
|
6
6
|
export { r as reqUrl } from './reqUrl-787dd9e5.js';
|
7
7
|
import './tslib.es6-35653116.js';
|
8
8
|
import 'dayjs';
|
package/dist/print.d.ts
CHANGED
@@ -21,7 +21,7 @@ interface IParams {
|
|
21
21
|
hiddenClassNames?: string[];
|
22
22
|
}
|
23
23
|
export declare function printCurrentDom({ hiddenClassNames }?: IParams): void;
|
24
|
-
export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, noWater, pdfOptions, imgPositionX, }: {
|
24
|
+
export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, noWater, pdfOptions, imgPositionX, waterText, }: {
|
25
25
|
pageClassName?: string;
|
26
26
|
dom: HTMLElement;
|
27
27
|
pdfName: string;
|
@@ -29,6 +29,7 @@ export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, noW
|
|
29
29
|
noWater?: boolean;
|
30
30
|
pdfOptions?: any;
|
31
31
|
imgPositionX?: number;
|
32
|
+
waterText?: string;
|
32
33
|
}): Promise<jsPDF>;
|
33
34
|
export declare function htmlToPdfUseCanvas({ pageClassName, dom, pdfName, isShowPage, noWater, pdfOptions, imgPositionX, isDownload, }: {
|
34
35
|
pageClassName?: string;
|
@@ -55,7 +56,7 @@ export interface IPdfOption {
|
|
55
56
|
/** 上下边距 */
|
56
57
|
pageMarginY?: number;
|
57
58
|
}
|
58
|
-
export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, fileBinary, pdfName, isDownload, pdfOption, isAddWater, waterBase64, imgWidth, imgHeight, isCompress, }: {
|
59
|
+
export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, fileBinary, pdfName, isDownload, pdfOption, isAddWater, waterBase64, imgWidth, imgHeight, isCompress, waterText, }: {
|
59
60
|
pageClassName?: string;
|
60
61
|
dom: HTMLElement;
|
61
62
|
isShowPage?: boolean;
|
@@ -70,5 +71,6 @@ export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, file
|
|
70
71
|
imgWidth?: number;
|
71
72
|
imgHeight?: number;
|
72
73
|
isCompress?: boolean;
|
74
|
+
waterText?: string;
|
73
75
|
}): Promise<unknown>;
|
74
76
|
export {};
|
package/dist/print.js
CHANGED
@@ -16,7 +16,7 @@ function addWaterHandle(_a) {
|
|
16
16
|
}
|
17
17
|
var canvasImg = createWaterHandle({
|
18
18
|
waterText: waterText,
|
19
|
-
});
|
19
|
+
}).imgBase64;
|
20
20
|
var styleDom = document.createElement('style');
|
21
21
|
styleDom.setAttribute('type', 'text/css');
|
22
22
|
styleDom.setAttribute('id', 'water-style-dom-110011');
|
@@ -77,8 +77,18 @@ function createWaterHandle(obj) {
|
|
77
77
|
var defaultWaterText = '浙商中拓';
|
78
78
|
var _a = obj || {}, waterText = _a.waterText, opacity = _a.opacity, fontSize = _a.fontSize, cavansWidth = _a.cavansWidth, cavansHeight = _a.cavansHeight;
|
79
79
|
var canvas = document.createElement('canvas');
|
80
|
-
|
81
|
-
|
80
|
+
var defaultCanvasWidth = waterText
|
81
|
+
? waterText.length > 10
|
82
|
+
? waterText.length * 22
|
83
|
+
: 240
|
84
|
+
: 240;
|
85
|
+
var defaultCanvasHeight = waterText
|
86
|
+
? waterText.length > 10
|
87
|
+
? waterText.length * 9
|
88
|
+
: 100
|
89
|
+
: 100;
|
90
|
+
canvas.width = cavansWidth || defaultCanvasWidth;
|
91
|
+
canvas.height = cavansHeight || defaultCanvasHeight;
|
82
92
|
var ctx = canvas.getContext('2d');
|
83
93
|
if (ctx) {
|
84
94
|
ctx.rotate((-10 * Math.PI) / 180); // 水印旋转角度
|
@@ -88,12 +98,22 @@ function createWaterHandle(obj) {
|
|
88
98
|
ctx.textBaseline = 'middle';
|
89
99
|
ctx.fillText(waterText || defaultWaterText, canvas.width / 2, canvas.height); // 水印在画布的位置x,y轴
|
90
100
|
}
|
91
|
-
return
|
101
|
+
return {
|
102
|
+
imgBase64: canvas.toDataURL('image/png'),
|
103
|
+
width: canvas.width,
|
104
|
+
height: canvas.height,
|
105
|
+
};
|
92
106
|
}
|
93
|
-
function addPdfWaterHandle(pdf, waterBase64) {
|
107
|
+
function addPdfWaterHandle(pdf, waterBase64, imgInfo) {
|
108
|
+
var width = 200;
|
109
|
+
var height = 80;
|
110
|
+
if (imgInfo) {
|
111
|
+
width = imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.width;
|
112
|
+
height = imgInfo === null || imgInfo === void 0 ? void 0 : imgInfo.height;
|
113
|
+
}
|
94
114
|
for (var i = 0; i < 10; i++) {
|
95
|
-
pdf.addImage(waterBase64, 'PNG', 40, 140 * i,
|
96
|
-
pdf.addImage(waterBase64, 'PNG',
|
115
|
+
pdf.addImage(waterBase64, 'PNG', 40, 140 * i, width, height, "1" + i);
|
116
|
+
pdf.addImage(waterBase64, 'PNG', 80 + width, 140 * i, width, height, "2" + i);
|
97
117
|
}
|
98
118
|
}
|
99
119
|
/**
|
@@ -122,22 +142,24 @@ function createPdf(canvas, pdf, noWater, positionX, options) {
|
|
122
142
|
if (leftHeight < pageHeight) {
|
123
143
|
pdf.addImage(pageData, 'JPEG', positionX || 20, 10, imgWidth, imgHeight);
|
124
144
|
if (!noWater) {
|
125
|
-
var
|
145
|
+
var _a = createWaterHandle({
|
126
146
|
opacity: '0.07',
|
127
147
|
fontSize: '14px',
|
128
|
-
|
129
|
-
|
148
|
+
waterText: (options === null || options === void 0 ? void 0 : options.waterText) || '',
|
149
|
+
}), waterBase64 = _a.imgBase64, width = _a.width, height = _a.height;
|
150
|
+
addPdfWaterHandle(pdf, waterBase64, { width: width, height: height });
|
130
151
|
}
|
131
152
|
}
|
132
153
|
else {
|
133
154
|
while (leftHeight > 0) {
|
134
155
|
pdf.addImage(pageData, 'JPEG', positionX || 20, position, imgWidth, imgHeight);
|
135
156
|
if (!noWater) {
|
136
|
-
var
|
157
|
+
var _b = createWaterHandle({
|
137
158
|
opacity: '0.07',
|
138
159
|
fontSize: '14px',
|
139
|
-
|
140
|
-
|
160
|
+
waterText: (options === null || options === void 0 ? void 0 : options.waterText) || '',
|
161
|
+
}), waterBase64 = _b.imgBase64, width = _b.width, height = _b.height;
|
162
|
+
addPdfWaterHandle(pdf, waterBase64, { width: width, height: height });
|
141
163
|
}
|
142
164
|
leftHeight -= pageHeight;
|
143
165
|
// position -= 841.89;
|
@@ -150,7 +172,7 @@ function createPdf(canvas, pdf, noWater, positionX, options) {
|
|
150
172
|
}
|
151
173
|
}
|
152
174
|
function htmlToPdf(_a) {
|
153
|
-
var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage, noWater = _a.noWater, pdfOptions = _a.pdfOptions, imgPositionX = _a.imgPositionX;
|
175
|
+
var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage, noWater = _a.noWater, pdfOptions = _a.pdfOptions, imgPositionX = _a.imgPositionX, waterText = _a.waterText;
|
154
176
|
var allDom = document.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
|
155
177
|
var format = (pdfOptions === null || pdfOptions === void 0 ? void 0 : pdfOptions.format) || [632.28, 841.89];
|
156
178
|
var pdf = new jsPDF(__assign({ unit: 'pt', format: format }, (pdfOptions || {})));
|
@@ -180,6 +202,7 @@ function htmlToPdf(_a) {
|
|
180
202
|
createPdf(canvas, pdf, noWater, imgPositionX, {
|
181
203
|
width: format === null || format === void 0 ? void 0 : format[0],
|
182
204
|
height: format === null || format === void 0 ? void 0 : format[1],
|
205
|
+
waterText: waterText,
|
183
206
|
});
|
184
207
|
if (i < promiseAllDomArray_1.length) {
|
185
208
|
pdf.addPage();
|
@@ -201,6 +224,7 @@ function htmlToPdf(_a) {
|
|
201
224
|
createPdf(canvas, pdf, noWater, imgPositionX, {
|
202
225
|
width: format === null || format === void 0 ? void 0 : format[0],
|
203
226
|
height: format === null || format === void 0 ? void 0 : format[1],
|
227
|
+
waterText: waterText,
|
204
228
|
});
|
205
229
|
pdf.save(pdfName + ".pdf");
|
206
230
|
return pdf;
|
@@ -277,7 +301,7 @@ function htmlToPdfUseCanvas(_a) {
|
|
277
301
|
}
|
278
302
|
function htmlToPdfNoCanvas(_a) {
|
279
303
|
var _b, _c;
|
280
|
-
var pageClassName = _a.pageClassName, dom = _a.dom, isShowPage = _a.isShowPage, fileBinary = _a.fileBinary, pdfName = _a.pdfName, isDownload = _a.isDownload, pdfOption = _a.pdfOption, isAddWater = _a.isAddWater, waterBase64 = _a.waterBase64, imgWidth = _a.imgWidth, imgHeight = _a.imgHeight, isCompress = _a.isCompress;
|
304
|
+
var pageClassName = _a.pageClassName, dom = _a.dom, isShowPage = _a.isShowPage, fileBinary = _a.fileBinary, pdfName = _a.pdfName, isDownload = _a.isDownload, pdfOption = _a.pdfOption, isAddWater = _a.isAddWater, waterBase64 = _a.waterBase64, imgWidth = _a.imgWidth, imgHeight = _a.imgHeight, isCompress = _a.isCompress; _a.waterText;
|
281
305
|
return __awaiter(this, void 0, void 0, function () {
|
282
306
|
var allDom, pageFormat, pageOrient, pageMarginX, pageMarginY, pdfOptions, allDomArray_1, pdfBase64_2, pdfs_2, pdf_2, pageWidth_1;
|
283
307
|
return __generator(this, function (_d) {
|