vg-print 1.1.2 → 1.1.202

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/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
  - npm搜索vg-print.
7
7
  - 联系我加 QQ: 984239686 或使用首页有微信加入群聊解决问题.
8
8
 
9
+ > **Vue 2 版本**: 如果你使用的是 Vue 2+webpack4.0以上,请查看 [vg-print](https://www.npmjs.com/package/vg-print-vue2)
10
+
9
11
  [vg-print开发者文档](https://www.yuque.com/designdev/vg-print)
10
12
 
11
13
  ## 授权密钥(authKey)与默认水印
Binary file
@@ -0,0 +1,87 @@
1
+ import { l as b } from "./index-NdItr7W8.js";
2
+ function M(e) {
3
+ return typeof e == "string" && /^data:image\/svg\+xml/i.test(e);
4
+ }
5
+ function C(e) {
6
+ let r = e.indexOf(",");
7
+ return r >= 0 ? decodeURIComponent(e.slice(r + 1)) : "";
8
+ }
9
+ function v(e) {
10
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`;
11
+ }
12
+ function F(e) {
13
+ let r = [], t = "", i = 0;
14
+ for (let o = 0; o < e.length; o++) {
15
+ let n = e[o];
16
+ n === "(" && i++, n === ")" && (i = Math.max(0, i - 1)), n === ";" && i === 0 ? (r.push(t), t = "") : t += n;
17
+ }
18
+ return t.trim() && r.push(t), r.map((o) => o.trim()).filter(Boolean);
19
+ }
20
+ function k(e) {
21
+ let r = [], t = "", i = 0;
22
+ for (let n = 0; n < e.length; n++) {
23
+ let s = e[n];
24
+ s === "(" && i++, s === ")" && (i = Math.max(0, i - 1)), s === "," && i === 0 ? (r.push(t.trim()), t = "") : t += s;
25
+ }
26
+ t.trim() && r.push(t.trim());
27
+ let o = [];
28
+ for (let n of r) {
29
+ if (/\binset\b/i.test(n)) continue;
30
+ let s = n.match(/-?\d+(?:\.\d+)?px/gi) || [], [l = "0px", a = "0px", m = "0px"] = s, u = n.replace(/-?\d+(?:\.\d+)?px/gi, "").replace(/\binset\b/ig, "").trim().replace(/\s{2,}/g, " "), d = !!u && u !== ",";
31
+ o.push(`drop-shadow(${l} ${a} ${m}${d ? ` ${u}` : ""})`);
32
+ }
33
+ return o.join(" ");
34
+ }
35
+ function y(e) {
36
+ let r = F(e), t = null, i = null, o = null, n = [];
37
+ for (let l of r) {
38
+ let a = l.indexOf(":");
39
+ if (a < 0) continue;
40
+ let m = l.slice(0, a).trim().toLowerCase(), u = l.slice(a + 1).trim();
41
+ m === "box-shadow" ? o = u : m === "filter" ? t = u : m === "-webkit-filter" ? i = u : n.push([m, u]);
42
+ }
43
+ if (o) {
44
+ let l = k(o);
45
+ l && (t = t ? `${t} ${l}` : l, i = i ? `${i} ${l}` : l);
46
+ }
47
+ let s = [...n];
48
+ return t && s.push(["filter", t]), i && s.push(["-webkit-filter", i]), s.map(([l, a]) => `${l}:${a}`).join(";");
49
+ }
50
+ function I(e) {
51
+ return e.replace(/([^{}]+)\{([^}]*)\}/g, (r, t, i) => `${t}{${y(i)}}`);
52
+ }
53
+ function N(e) {
54
+ return e = e.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, (r, t) => r.replace(t, I(t))), e = e.replace(/style=(['"])([\s\S]*?)\1/gi, (r, t, i) => `style=${t}${y(i)}${t}`), e;
55
+ }
56
+ function S(e) {
57
+ if (!b() || !M(e)) return e;
58
+ try {
59
+ let r = C(e), t = N(r);
60
+ return v(t);
61
+ } catch {
62
+ return e;
63
+ }
64
+ }
65
+ async function R(e, r) {
66
+ let { width: t, height: i, scale: o = 1, dpr: n = 1, meta: s = {}, backgroundColor: l } = r;
67
+ e = S(e);
68
+ let a = new Image();
69
+ a.loading = "eager", a.decoding = "sync", a.crossOrigin = "anonymous", a.src = e, await a.decode();
70
+ let m = a.naturalWidth, u = a.naturalHeight, d = Number.isFinite(s.w0) ? s.w0 : m, x = Number.isFinite(s.h0) ? s.h0 : u, c, f, $ = Number.isFinite(t), w = Number.isFinite(i);
71
+ if ($ && w) c = Math.max(1, t), f = Math.max(1, i);
72
+ else if ($) {
73
+ let g = t / Math.max(1, d);
74
+ c = t, f = x * g;
75
+ } else if (w) {
76
+ let g = i / Math.max(1, x);
77
+ f = i, c = d * g;
78
+ } else c = m, f = u;
79
+ c = c * o, f = f * o;
80
+ let h = document.createElement("canvas");
81
+ h.width = c * n, h.height = f * n, h.style.width = `${c}px`, h.style.height = `${f}px`;
82
+ let p = h.getContext("2d");
83
+ return n !== 1 && p.scale(n, n), l && (p.save(), p.fillStyle = l, p.fillRect(0, 0, c, f), p.restore()), p.drawImage(a, 0, 0, c, f), h;
84
+ }
85
+ export {
86
+ R as W
87
+ };
@@ -0,0 +1,8 @@
1
+ import { W as a } from "./chunk-MW6X4KTL-RIoq2607.js";
2
+ async function o(r, t) {
3
+ let i = await a(r, t), e = new Image();
4
+ return e.src = i.toDataURL(`image/${t.format}`, t.quality), await e.decode(), e.style.width = `${i.width / t.dpr}px`, e.style.height = `${i.height / t.dpr}px`, e;
5
+ }
6
+ export {
7
+ o as d
8
+ };
@@ -0,0 +1,13 @@
1
+ import { W as m } from "./chunk-MW6X4KTL-RIoq2607.js";
2
+ async function a(n, e) {
3
+ let o = e.type;
4
+ if (o === "svg") {
5
+ let t = decodeURIComponent(n.split(",")[1]);
6
+ return new Blob([t], { type: "image/svg+xml" });
7
+ }
8
+ let i = await m(n, e);
9
+ return new Promise((t) => i.toBlob((l) => t(l), `image/${o}`, e.quality));
10
+ }
11
+ export {
12
+ a as m
13
+ };
@@ -0,0 +1,297 @@
1
+
2
+ @media print {
3
+ body {
4
+ margin: 0px;
5
+ padding: 0px;
6
+ }
7
+ }
8
+
9
+ @page {
10
+ margin: 0;
11
+ }
12
+
13
+ .hiprint-printPaper * {
14
+ box-sizing: border-box;
15
+ -moz-box-sizing: border-box; /* Firefox */
16
+ -webkit-box-sizing: border-box; /* Safari */
17
+ image-rendering: -webkit-optimize-contrast; /* 让图片/标尺稍微清楚一点 */
18
+ }
19
+
20
+ .hiprint-printPaper *:focus {
21
+ outline: -webkit-focus-ring-color auto 0px;
22
+ }
23
+
24
+
25
+ .hiprint-page-break-avoid {
26
+ page-break-after: avoid;
27
+ }
28
+ .hiprint-printPaper {
29
+ position: relative;
30
+ padding: 0 0 0 0;
31
+ page-break-after: always;
32
+ -webkit-user-select: none; /* Chrome/Safari/Opera */
33
+ -moz-user-select: none; /* Firefox */
34
+ user-select: none;
35
+ overflow-x: hidden;
36
+ overflow: hidden;
37
+ }
38
+ .hiprint-printPaper .hiprint-printPaper-content {
39
+ position: relative;
40
+ }
41
+ .hiprint-printPaper.design {
42
+ overflow: visible;
43
+ }
44
+
45
+
46
+
47
+ .hiprint-printTemplate .hiprint-printPanel {
48
+ page-break-after: always;
49
+ }
50
+
51
+ .hiprint-printPaper, hiprint-printPanel {
52
+ box-sizing: border-box;
53
+ border: 0px;
54
+ }
55
+
56
+ .hiprint-printPanel .hiprint-printPaper:last-child {
57
+ page-break-after: avoid;
58
+ }
59
+
60
+ .hiprint-printTemplate .hiprint-printPanel:last-child {
61
+ page-break-after: avoid;
62
+ }
63
+
64
+ .hiprint-printPaper .hideheaderLinetarget {
65
+ border-top: 0px dashed rgb(201, 190, 190) !important;
66
+ }
67
+
68
+ .hiprint-printPaper .hidefooterLinetarget {
69
+ border-top: 0px dashed rgb(201, 190, 190) !important;
70
+ }
71
+
72
+ .hiprint-printPaper.design {
73
+ border: 1px dashed rgba(170,170,170,0.7);
74
+ }
75
+
76
+ .design .hiprint-printElement-table-content, .design .hiprint-printElement-longText-content {
77
+ overflow: hidden;
78
+ box-sizing: border-box;
79
+ }
80
+
81
+ .design .resize-panel {
82
+ box-sizing: border-box;
83
+ border: 1px dotted;
84
+ }
85
+
86
+ .hiprint-printElement-text {
87
+ background-color: transparent;
88
+ background-repeat: repeat;
89
+ padding: 0 0 0 0;
90
+ border: 0.75pt none rgb(0,0,0);
91
+ direction: ltr;
92
+ font-family: 'SimSun';
93
+ font-size: 9pt;
94
+ font-style: normal;
95
+ font-weight: normal;
96
+ padding-bottom: 0pt;
97
+ padding-left: 0pt;
98
+ padding-right: 0pt;
99
+ padding-top: 0pt;
100
+ text-align: left;
101
+ text-decoration: none;
102
+ line-height: 9.75pt;
103
+ box-sizing: border-box;
104
+ word-wrap: break-word;
105
+ word-break: break-all;
106
+ }
107
+
108
+ .design .hiprint-printElement-text-content {
109
+ border: 1px dashed rgb(206, 188, 188);
110
+ box-sizing: border-box;
111
+ }
112
+
113
+ .hiprint-printElement-longText {
114
+ background-color: transparent;
115
+ background-repeat: repeat;
116
+ border: 0.75pt none rgb(0,0,0);
117
+ direction: ltr;
118
+ font-family: 'SimSun';
119
+ font-size: 9pt;
120
+ font-style: normal;
121
+ font-weight: normal;
122
+ padding-bottom: 0pt;
123
+ padding-left: 0pt;
124
+ padding-right: 0pt;
125
+ padding-top: 0pt;
126
+ text-align: left;
127
+ text-decoration: none;
128
+ line-height: 9.75pt;
129
+ box-sizing: border-box;
130
+ word-wrap: break-word;
131
+ word-break: break-all;
132
+ /*white-space: pre-wrap*/
133
+ }
134
+
135
+
136
+
137
+ .hiprint-printElement-table {
138
+ background-color: transparent;
139
+ background-repeat: repeat;
140
+ color: rgb(0,0,0);
141
+ border-color: rgb(0,0,0);
142
+ border-style: none;
143
+ direction: ltr;
144
+ font-family: 'SimSun';
145
+ font-size: 9pt;
146
+ font-style: normal;
147
+ font-weight: normal;
148
+ padding-bottom: 0pt;
149
+ padding-left: 0pt;
150
+ padding-right: 0pt;
151
+ padding-top: 0pt;
152
+ text-align: left;
153
+ text-decoration: none;
154
+ padding: 0 0 0 0;
155
+ box-sizing: border-box;
156
+ line-height: 9.75pt;
157
+ }
158
+
159
+ .hiprint-printElement-table thead {
160
+ background: #e8e8e8;
161
+ font-weight: 700;
162
+ }
163
+
164
+ .hiprint-printElement-tableTarget, .hiprint-printElement-tableTarget tr, .hiprint-printElement-tableTarget td {
165
+ border-color: rgb(0,0,0);
166
+ /*border-style: none;*/
167
+ /*border: 1px solid rgb(0,0,0);*/
168
+ font-weight: normal;
169
+ direction: ltr;
170
+ padding-bottom: 0pt;
171
+ padding-left: 4pt;
172
+ padding-right: 4pt;
173
+ padding-top: 0pt;
174
+ text-decoration: none;
175
+ vertical-align: middle;
176
+ box-sizing: border-box;
177
+ word-wrap: break-word;
178
+ word-break: break-all;
179
+ /*line-height: 9.75pt;
180
+ font-size: 9pt;*/
181
+ }
182
+
183
+ /*.hiprint-printElement-tableTarget tr,*/
184
+ .hiprint-printElement-tableTarget td {
185
+ height: 18pt;
186
+ }
187
+
188
+ /* 边框样式(用于打印时保持边框) */
189
+ table.hiprint-printElement-tableTarget { width: 100%; }
190
+ .hiprint-printElement-tableTarget-border-all { border: 1px solid; }
191
+ .hiprint-printElement-tableTarget-border-none { border: 0px solid; }
192
+ .hiprint-printElement-tableTarget-border-lr { border-left: 1px solid; border-right: 1px solid; }
193
+ .hiprint-printElement-tableTarget-border-left { border-left: 1px solid; }
194
+ .hiprint-printElement-tableTarget-border-right { border-right: 1px solid; }
195
+ .hiprint-printElement-tableTarget-border-tb { border-top: 1px solid; border-bottom: 1px solid; }
196
+ .hiprint-printElement-tableTarget-border-top { border-top: 1px solid; }
197
+ .hiprint-printElement-tableTarget-border-bottom { border-bottom: 1px solid; }
198
+ .hiprint-printElement-tableTarget-border-td-none td { border: 0px solid; }
199
+ .hiprint-printElement-tableTarget-border-td-all td:not(:nth-last-child(-n+2)) { border-right: 1px solid; }
200
+ .hiprint-printElement-tableTarget-border-td-all td { border-left: 1px solid; }
201
+ .hiprint-printElement-tableTarget-border-td-all td:last-child:first-child { border-left: none; }
202
+
203
+ .hiprint-printPaper .hiprint-paperNumber {
204
+ font-size: 9pt;
205
+ }
206
+
207
+ .design .hiprint-printElement-table-handle {
208
+ position: absolute;
209
+ height: 12pt;
210
+ width: 12pt;
211
+ background: red;
212
+ z-index:1;
213
+ }
214
+
215
+ .hiprint-printPaper .hiprint-paperNumber-disabled {
216
+ float: right !important;
217
+ right: 0 !important;
218
+ color: gainsboro !important;
219
+ }
220
+
221
+ .hiprint-printElement-vline, .hiprint-printElement-hline {
222
+ border: 0px none rgb(0,0,0);
223
+
224
+ }
225
+ .hiprint-printElement-vline {
226
+ border-left: 0.75pt solid #000;
227
+ border-right: 0px none rgb(0,0,0) !important;
228
+ border-bottom: 0px none rgb(0,0,0) !important;
229
+ border-top: 0px none rgb(0,0,0) !important;
230
+ }
231
+
232
+ .hiprint-printElement-hline {
233
+ border-top: 0.75pt solid #000;
234
+ border-right: 0px none rgb(0,0,0) !important;
235
+ border-bottom: 0px none rgb(0,0,0) !important;
236
+ border-left: 0px none rgb(0,0,0) !important;
237
+ }
238
+
239
+ .hiprint-printElement-oval, .hiprint-printElement-rect {
240
+ border: 0.75pt solid #000;
241
+ }
242
+
243
+ .hiprint-text-content-middle {
244
+ display:table;
245
+ }
246
+ .hiprint-text-content-middle>div {
247
+ display: table-cell;
248
+ vertical-align:middle
249
+ }
250
+
251
+ .hiprint-text-content-bottom {
252
+ display: table;
253
+ }
254
+
255
+ .hiprint-text-content-bottom > div {
256
+ display: table-cell;
257
+ vertical-align: bottom
258
+ }
259
+
260
+ /*hi-grid-row */
261
+ .hi-grid-row {
262
+ position: relative;
263
+ height: auto;
264
+ margin-right: 0;
265
+ margin-left: 0;
266
+ zoom: 1;
267
+ display: block;
268
+ box-sizing: border-box;
269
+ }
270
+
271
+ .hi-grid-row::after, .hi-grid-row::before {
272
+ display: table;
273
+ content: '';
274
+ box-sizing: border-box;
275
+ }
276
+
277
+ .hi-grid-col {
278
+ display: block;
279
+ box-sizing: border-box;
280
+ position: relative;
281
+ float: left;
282
+ flex: 0 0 auto;
283
+ }
284
+
285
+ .table-grid-row {
286
+ margin-left: -0pt;
287
+ margin-right: -0pt;
288
+ }
289
+
290
+ .tableGridColumnsGutterRow {
291
+ padding-left: 0pt;
292
+ padding-right: 0pt;
293
+ }
294
+ .hiprint-gridColumnsFooter {
295
+ text-align: left;
296
+ clear: both;
297
+ }
@@ -0,0 +1,15 @@
1
+ import { m as f } from "./chunk-Y7FY32AO-B_5TIb6p.js";
2
+ import { W as t } from "./chunk-MW6X4KTL-RIoq2607.js";
3
+ async function w(n, e) {
4
+ let c = ((e == null ? void 0 : e.format) || (e == null ? void 0 : e.type) || "").toLowerCase(), a = c === "jpg" ? "jpeg" : c || "png", i = (e == null ? void 0 : e.filename) || `snapdom.${a}`, o = { ...e || {}, format: a, type: a };
5
+ if (o.dpr = 1, a === "svg") {
6
+ let d = await f(n, { ...o, type: "svg" }), l = URL.createObjectURL(d), m = document.createElement("a");
7
+ m.href = l, m.download = i, m.click(), URL.revokeObjectURL(l);
8
+ return;
9
+ }
10
+ let p = await t(n, o), r = document.createElement("a");
11
+ r.href = p.toDataURL(`image/${a}`, e == null ? void 0 : e.quality), r.download = i, r.click();
12
+ }
13
+ export {
14
+ w as download
15
+ };
Binary file