vg-print-vue2 1.0.603 → 1.0.604

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
@@ -118,7 +118,34 @@ async function exportReport(templateJson, printData, pdfOptions = {}) {
118
118
 
119
119
  原 `template.toPdf(data, name, options)`、`exportPdf()` 的参数、分页、标签拼版及返回值保持一致;例如 `isDownload: false, type: 'blob'` 可返回 PDF 数据。`clientGenerate()` 需要先生成 PDF,所以也必须注册该插件。
120
120
 
121
- 未注入时,Preview 和 Header 的 PDF 按钮自动隐藏;Preview 的 `showPdf` / `show({ showPdf })` 及 Header 的 `showPdf` 仍可主动隐藏按钮。直接调用导出入口会提示缺少插件。库入口不内置插件,示例入口已注册;图片导出继续由核心提供。
121
+ 未注入时,Preview 和 Header 的 PDF 按钮自动隐藏;Preview 的 `showPdf` / `show({ showPdf })` 及 Header 的 `showPdf` 仍可主动隐藏按钮。直接调用导出入口会提示缺少插件。库入口不内置插件,示例入口已注册。
122
+
123
+ ### 可选图片导出插件
124
+
125
+ 图片导出已拆为 `@vg-print/plugin-api-image`,与 Vue 3 共用同一个插件;注册后原 `template.toImage(data, options)`、`exportImage()`、设计器和预览组件的图片导出继续使用。
126
+
127
+ ```bash
128
+ npm install @vg-print/plugin-api-image
129
+ ```
130
+
131
+ ```js
132
+ import { hiprint, createTemplate } from 'vg-print-vue2'
133
+ import pluginApiImage from '@vg-print/plugin-api-image'
134
+
135
+ async function exportImages(templateJson, printData) {
136
+ // 挂载设计器 / 预览组件前注入,可与 PDF、Word 插件一起注册。
137
+ await hiprint.register({ plugins: [pluginApiImage()] })
138
+ const template = createTemplate(templateJson)
139
+ return template.toImage(printData, {
140
+ isDownload: true, name: '报告', limit: 1,
141
+ type: 'image/png', pixelRatio: 2, toType: 'blob'
142
+ })
143
+ }
144
+ ```
145
+
146
+ 未注入时 Header / Preview 的图片按钮自动隐藏,外部导出入口提示缺少插件。Header 的 `showImage` / FullDesigner 的 `show-option.showImage`、Preview 的 `showImg` / `show({ showImg })` 继续控制显示。图片和 PDF 插件独立;`clientGenerate()` 仍走 PDF 数据到客户端的流程,依赖 PDF 插件。
147
+
148
+ 核心不再直接导入或依赖 html2canvas / snapdom,由图片和 PDF 插件按需带入。开发示例使用 `file:../api-image` 与 Vite 别名,库入口不注册图片插件。默认值、分页、长图合并、标签拼版、进度和 Deferred 返回语义保持原实现;详见 [图片插件说明](../api-image/README.md)。
122
149
 
123
150
  ## 静默打印客户端工具安装包
124
151
 
@@ -1401,20 +1428,22 @@ exportPdf(tpl, printData, '打印预览pdf', {
1401
1428
 
1402
1429
  ### 导出图片(toImage / exportImage)
1403
1430
 
1431
+ 需先安装并通过 `hiprint.register({ plugins: [pluginApiImage()] })` 注册图片插件,参见“可选图片导出插件”。默认不下载、每 10 页合并一张、截图倍率为 2;成功时下载与不下载都返回 URL/Blob 数组。
1432
+
1404
1433
  > `exportImage(tpl, data, options)` 本质调用的是模板实例的 `tpl.toImage(data, options)`;两者参数一致。
1405
1434
 
1406
1435
  #### 模式 A:普通导出(按模板分页导出图片)
1407
1436
 
1408
1437
  ```js
1409
1438
  // 不传 paperWidth/paperHeight:按模板分页导出
1410
- // splitPages: true 表示“每页一张图片”(推荐:避免长图占用太大内存)
1439
+ // limit: 1 表示每页一张图片;原方法未实现 splitPages 开关
1411
1440
  await exportImage(tpl, printData, {
1412
1441
  isDownload: true,
1413
1442
  name: '图片',
1414
- splitPages: true,
1443
+ limit: 1,
1415
1444
  type: 'image/png', // 含二维码/条码建议 png;纯文字/照片可 jpeg
1416
1445
  pixelRatio: 2,
1417
- quality: 0.8, // 仅 JPEG 有效(0-1)
1446
+ quality: 0.8, // JPEG / WebP 编码质量(0-1)
1418
1447
  toType: 'blob', // 推荐 blob(避免大 dataURL 阻塞)
1419
1448
  onProgress: (cur, total) => console.log('toImage 进度', Math.floor((cur / total) * 100))
1420
1449
  })
@@ -1445,21 +1474,22 @@ await exportImage(tpl, printData, {
1445
1474
  limit: 6, // 每张“纸”放 6 个(不够的到下一张)
1446
1475
  isDownload: true,
1447
1476
  name: 'A4排版',
1448
- splitPages: true, // 每张纸输出一张图片(文件名自动追加 -1/-2/...)
1477
+ // 网格拼版时每张纸独立输出一张图片(文件名自动追加 -1/-2/...)
1449
1478
  type: 'image/png',
1450
1479
  pixelRatio: 2
1451
1480
  })
1452
1481
  ```
1453
1482
 
1454
- #### 排版规则(重点:limit=0/不传的行为)
1483
+ #### 排版规则(沿用原方法)
1455
1484
 
1456
1485
  - 传入了纸张宽高(`paperWidth/paperHeight`)时:
1457
- - `limit > 0`:强制“每张纸 N 个”(等同于 PDF 的 `perPage`)。
1458
- - `limit = 0` 或不传 `limit`:自动计算“一张纸能放几个放几个”。
1486
+ - `perPage` 优先于 `limit`,未传两者时默认 10,并受纸张实际容量限制。
1487
+ - `perPage=0`(或仅 `limit=0`)自动填满;有效 perPage 大于 1 时指定每张纸数量。
1488
+ - 有效 `perPage=1` 不触发网格拼版,继续走普通分页。
1459
1489
  - 没有传纸张宽高时:
1460
- - `splitPages: true`:每页一张图(推荐)。
1461
- - `splitPages: false` 且 `limit > 0`:每 N 页合成长图。
1462
- - `splitPages: false` 且 `limit <= 0`:所有页合成一张超长图(不推荐)。
1490
+ - `limit=1`:每页一张图;未传 limit 默认每 10 页合成长图。
1491
+ - `limit>0`:每 N 页合成长图;`limit<=0`:所有页合成一张超长图。
1492
+ - 原图片方法没有实现 `splitPages` 开关,传入它不会改变分组。
1463
1493
 
1464
1494
  ***
1465
1495
 
@@ -1469,18 +1499,17 @@ await exportImage(tpl, printData, {
1469
1499
  - `usePaperType`:PDF/图片可用;为 `true` 时按模板的 `paperType`(如 A4)设置页面尺寸。
1470
1500
  - `scale` / `pixelRatio`:渲染缩放;`pixelRatio` 优先级高于 `scale`。值越大越清晰,但越耗时/耗内存。
1471
1501
  - `perPage`:PDF 排版模式每页模板数量;`0/不传` 表示自动填充。
1472
- - `limit`:图片普通模式下用于“每 N 页合成长图”;图片排版模式下等同于“每张纸 N 个”;`0/不传` 表示自动填充(排版模式)或全量合成(普通模式,谨慎)。
1473
- - `splitPages`:图片每页/每张纸输出一张(推荐)。
1502
+ - `limit`:图片默认 10;普通模式每 N 页合成长图,<=0 全量合成。拼版时作为 perPage 的后备值,0 自动填满,1 不触发网格。
1503
+ - `splitPages`:原图片方法未实现;普通模式每页一张请设置 limit=1,网格拼版模式自动每纸一张。
1474
1504
  - `type`:图片格式;`'image/jpeg'` 或 `'image/png'`(二维码/条码建议 png)。
1475
- - `quality`:图片质量(0-1,仅 JPEG 有效)。
1505
+ - `quality`:图片质量(0-1,JPEG / WebP 有效)。
1476
1506
  - `toType`:返回类型(不下载时);`'url'` 或 `'blob'`。
1477
1507
  - `isDownload`:是否自动触发下载。
1478
1508
  - `name`:文件名(图片会自动追加页码后缀)。
1479
1509
  - `leftOffset`、`topOffset`:排版对齐偏移(mm);`-1` 表示居中,`>=0` 表示边距。
1480
1510
  - `onProgress(cur, total)`:导出进度回调;以 `cur/total` 计算百分比。
1481
1511
  - `forcePng`(PDF):强制使用 PNG 写入 PDF(条码/二维码建议开启)。
1482
- - `maxCanvasPixels`:单页最大画布像素上限;导出卡顿/崩溃时可调小(例如 `2e7`)。
1483
- - `debugPerf`:输出每页渲染耗时到控制台,便于定位慢点。
1512
+ - 图片方法未实现 `maxCanvasPixels` / `debugPerf` 内置控制,其他扩展参数仍原样透传给 getHtml / 截图库。
1484
1513
 
1485
1514
 
1486
1515
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vg-print-vue2",
3
3
  "description": "vg-print supports visual drag and drop design templates, with functions such as previewing and exporting PDFs/images. Silent printing can be achieved in conjunction with a dedicated client",
4
- "version": "1.0.603",
4
+ "version": "1.0.604",
5
5
  "author": "gmcSimple",
6
6
  "license": "MIT",
7
7
  "main": "dist/vg-print-vue2.cjs.js",
@@ -47,7 +47,8 @@
47
47
  "not ie <= 8"
48
48
  ],
49
49
  "devDependencies": {
50
- "@vg-print/plugin-api-pdf": "0.1.1",
50
+ "@vg-print/plugin-api-image": "^0.1.2",
51
+ "@vg-print/plugin-api-pdf": "^0.1.1",
51
52
  "@vg-print/plugin-api-word": "^0.1.8",
52
53
  "@vg-print/plugin-bwip-js": "^0.1.2",
53
54
  "@vg-print/plugin-code-editor": "^0.1.9",
@@ -63,6 +64,7 @@
63
64
  "vue-template-compiler": "^2.7.16"
64
65
  },
65
66
  "peerDependencies": {
67
+ "@vg-print/plugin-api-image": "^0.1.2",
66
68
  "@vg-print/plugin-api-pdf": "^0.1.1",
67
69
  "@vg-print/plugin-api-word": "^0.1.8",
68
70
  "@vg-print/plugin-bwip-js": "^0.1.2",
@@ -73,6 +75,9 @@
73
75
  "vue": ">=2.7.0 <3"
74
76
  },
75
77
  "peerDependenciesMeta": {
78
+ "@vg-print/plugin-api-image": {
79
+ "optional": true
80
+ },
76
81
  "@vg-print/plugin-api-pdf": {
77
82
  "optional": true
78
83
  },
@@ -98,9 +103,7 @@
98
103
  "dependencies": {
99
104
  "@claviska/jquery-minicolors": "^2.3.6",
100
105
  "@noble/curves": "^1.9.7",
101
- "@zumer/snapdom": "^2.0.2",
102
106
  "canvg": "^3.0.10",
103
- "html2canvas": "^1.4.1",
104
107
  "jquery": "^3.7.1",
105
108
  "jsbarcode": "^3.11.5",
106
109
  "nzh": "^1.0.8",
Binary file
@@ -1,307 +0,0 @@
1
-
2
- @media print {
3
- /* Cancel the designer viewport rule when this file is loaded by the
4
- browser-print iframe. */
5
- html,
6
- body {
7
- height: auto !important;
8
- min-height: 0 !important;
9
- overflow: visible !important;
10
- }
11
- body {
12
- margin: 0px;
13
- padding: 0px;
14
- }
15
- }
16
-
17
- @page {
18
- margin: 0;
19
- }
20
-
21
- .hiprint-printPaper * {
22
- box-sizing: border-box;
23
- -moz-box-sizing: border-box; /* Firefox */
24
- -webkit-box-sizing: border-box; /* Safari */
25
- image-rendering: -webkit-optimize-contrast; /* 让图片/标尺稍微清楚一点 */
26
- }
27
-
28
- .hiprint-printPaper *:focus {
29
- outline: -webkit-focus-ring-color auto 0px;
30
- }
31
-
32
-
33
- .hiprint-page-break-avoid {
34
- page-break-after: avoid;
35
- }
36
- .hiprint-printPaper {
37
- position: relative;
38
- padding: 0 0 0 0;
39
- page-break-after: always;
40
- break-after: page;
41
- break-inside: avoid;
42
- -webkit-user-select: none; /* Chrome/Safari/Opera */
43
- -moz-user-select: none; /* Firefox */
44
- user-select: none;
45
- overflow-x: hidden;
46
- overflow: hidden;
47
- }
48
- .hiprint-printPaper .hiprint-printPaper-content {
49
- position: relative;
50
- }
51
- .hiprint-printPaper.design {
52
- overflow: visible;
53
- }
54
-
55
-
56
-
57
- .hiprint-printTemplate .hiprint-printPanel {
58
- page-break-after: always;
59
- }
60
-
61
- .hiprint-printPaper, hiprint-printPanel {
62
- box-sizing: border-box;
63
- border: 0px;
64
- }
65
-
66
- .hiprint-printPanel .hiprint-printPaper:last-child {
67
- page-break-after: avoid;
68
- }
69
-
70
- .hiprint-printTemplate .hiprint-printPanel:last-child {
71
- page-break-after: avoid;
72
- }
73
-
74
- .hiprint-printPaper .hideheaderLinetarget {
75
- border-top: 0px dashed rgb(201, 190, 190) !important;
76
- }
77
-
78
- .hiprint-printPaper .hidefooterLinetarget {
79
- border-top: 0px dashed rgb(201, 190, 190) !important;
80
- }
81
-
82
- .hiprint-printPaper.design {
83
- border: 1px dashed rgba(170,170,170,0.7);
84
- }
85
-
86
- .design .hiprint-printElement-table-content, .design .hiprint-printElement-longText-content {
87
- overflow: hidden;
88
- box-sizing: border-box;
89
- }
90
-
91
- .design .resize-panel {
92
- box-sizing: border-box;
93
- border: 1px dotted;
94
- }
95
-
96
- .hiprint-printElement-text {
97
- background-color: transparent;
98
- background-repeat: repeat;
99
- padding: 0 0 0 0;
100
- border: 0.75pt none rgb(0,0,0);
101
- direction: ltr;
102
- font-family: 'SimSun';
103
- font-size: 9pt;
104
- font-style: normal;
105
- font-weight: normal;
106
- padding-bottom: 0pt;
107
- padding-left: 0pt;
108
- padding-right: 0pt;
109
- padding-top: 0pt;
110
- text-align: left;
111
- text-decoration: none;
112
- line-height: 9.75pt;
113
- box-sizing: border-box;
114
- word-wrap: break-word;
115
- word-break: break-all;
116
- }
117
-
118
- .design .hiprint-printElement-text-content {
119
- border: 1px dashed rgb(206, 188, 188);
120
- box-sizing: border-box;
121
- }
122
-
123
- .hiprint-printElement-longText {
124
- background-color: transparent;
125
- background-repeat: repeat;
126
- border: 0.75pt none rgb(0,0,0);
127
- direction: ltr;
128
- font-family: 'SimSun';
129
- font-size: 9pt;
130
- font-style: normal;
131
- font-weight: normal;
132
- padding-bottom: 0pt;
133
- padding-left: 0pt;
134
- padding-right: 0pt;
135
- padding-top: 0pt;
136
- text-align: left;
137
- text-decoration: none;
138
- line-height: 9.75pt;
139
- box-sizing: border-box;
140
- word-wrap: break-word;
141
- word-break: break-all;
142
- /*white-space: pre-wrap*/
143
- }
144
-
145
-
146
-
147
- .hiprint-printElement-table {
148
- background-color: transparent;
149
- background-repeat: repeat;
150
- color: rgb(0,0,0);
151
- border-color: rgb(0,0,0);
152
- border-style: none;
153
- direction: ltr;
154
- font-family: 'SimSun';
155
- font-size: 9pt;
156
- font-style: normal;
157
- font-weight: normal;
158
- padding-bottom: 0pt;
159
- padding-left: 0pt;
160
- padding-right: 0pt;
161
- padding-top: 0pt;
162
- text-align: left;
163
- text-decoration: none;
164
- padding: 0 0 0 0;
165
- box-sizing: border-box;
166
- line-height: 9.75pt;
167
- }
168
-
169
- .hiprint-printElement-table thead {
170
- background: #e8e8e8;
171
- font-weight: 700;
172
- }
173
-
174
- .hiprint-printElement-tableTarget, .hiprint-printElement-tableTarget tr, .hiprint-printElement-tableTarget td {
175
- border-color: rgb(0,0,0);
176
- /*border-style: none;*/
177
- /*border: 1px solid rgb(0,0,0);*/
178
- font-weight: normal;
179
- direction: ltr;
180
- padding-bottom: 0pt;
181
- padding-left: 4pt;
182
- padding-right: 4pt;
183
- padding-top: 0pt;
184
- text-decoration: none;
185
- vertical-align: middle;
186
- box-sizing: border-box;
187
- word-wrap: break-word;
188
- word-break: break-all;
189
- /*line-height: 9.75pt;
190
- font-size: 9pt;*/
191
- }
192
-
193
- /*.hiprint-printElement-tableTarget tr,*/
194
- .hiprint-printElement-tableTarget td {
195
- height: 18pt;
196
- }
197
-
198
- /* 边框样式(用于打印时保持边框) */
199
- table.hiprint-printElement-tableTarget { width: 100%; }
200
- .hiprint-printElement-tableTarget-border-all { border: 1px solid; }
201
- .hiprint-printElement-tableTarget-border-none { border: 0px solid; }
202
- .hiprint-printElement-tableTarget-border-lr { border-left: 1px solid; border-right: 1px solid; }
203
- .hiprint-printElement-tableTarget-border-left { border-left: 1px solid; }
204
- .hiprint-printElement-tableTarget-border-right { border-right: 1px solid; }
205
- .hiprint-printElement-tableTarget-border-tb { border-top: 1px solid; border-bottom: 1px solid; }
206
- .hiprint-printElement-tableTarget-border-top { border-top: 1px solid; }
207
- .hiprint-printElement-tableTarget-border-bottom { border-bottom: 1px solid; }
208
- .hiprint-printElement-tableTarget-border-td-none td { border: 0px solid; }
209
- .hiprint-printElement-tableTarget-border-td-all td:not(:nth-last-child(-n+2)) { border-right: 1px solid; }
210
- .hiprint-printElement-tableTarget-border-td-all td { border-left: 1px solid; }
211
- .hiprint-printElement-tableTarget-border-td-all td:last-child:first-child { border-left: none; }
212
-
213
- .hiprint-printPaper .hiprint-paperNumber {
214
- font-size: 9pt;
215
- }
216
-
217
- .design .hiprint-printElement-table-handle {
218
- position: absolute;
219
- height: 12pt;
220
- width: 12pt;
221
- background: red;
222
- z-index:1;
223
- }
224
-
225
- .hiprint-printPaper .hiprint-paperNumber-disabled {
226
- float: right !important;
227
- right: 0 !important;
228
- color: gainsboro !important;
229
- }
230
-
231
- .hiprint-printElement-vline, .hiprint-printElement-hline {
232
- border: 0px none rgb(0,0,0);
233
-
234
- }
235
- .hiprint-printElement-vline {
236
- border-left: 0.75pt solid #000;
237
- border-right: 0px none rgb(0,0,0) !important;
238
- border-bottom: 0px none rgb(0,0,0) !important;
239
- border-top: 0px none rgb(0,0,0) !important;
240
- }
241
-
242
- .hiprint-printElement-hline {
243
- border-top: 0.75pt solid #000;
244
- border-right: 0px none rgb(0,0,0) !important;
245
- border-bottom: 0px none rgb(0,0,0) !important;
246
- border-left: 0px none rgb(0,0,0) !important;
247
- }
248
-
249
- .hiprint-printElement-oval, .hiprint-printElement-rect {
250
- border: 0.75pt solid #000;
251
- }
252
-
253
- .hiprint-text-content-middle {
254
- display:table;
255
- }
256
- .hiprint-text-content-middle>div {
257
- display: table-cell;
258
- vertical-align:middle
259
- }
260
-
261
- .hiprint-text-content-bottom {
262
- display: table;
263
- }
264
-
265
- .hiprint-text-content-bottom > div {
266
- display: table-cell;
267
- vertical-align: bottom
268
- }
269
-
270
- /*hi-grid-row */
271
- .hi-grid-row {
272
- position: relative;
273
- height: auto;
274
- margin-right: 0;
275
- margin-left: 0;
276
- zoom: 1;
277
- display: block;
278
- box-sizing: border-box;
279
- }
280
-
281
- .hi-grid-row::after, .hi-grid-row::before {
282
- display: table;
283
- content: '';
284
- box-sizing: border-box;
285
- }
286
-
287
- .hi-grid-col {
288
- display: block;
289
- box-sizing: border-box;
290
- position: relative;
291
- float: left;
292
- flex: 0 0 auto;
293
- }
294
-
295
- .table-grid-row {
296
- margin-left: -0pt;
297
- margin-right: -0pt;
298
- }
299
-
300
- .tableGridColumnsGutterRow {
301
- padding-left: 0pt;
302
- padding-right: 0pt;
303
- }
304
- .hiprint-gridColumnsFooter {
305
- text-align: left;
306
- clear: both;
307
- }
package/dist/favicon.ico DELETED
Binary file