vg-print-vue2 1.0.209 → 1.0.211
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.en.md +2 -5
- package/README.md +8 -31
- package/dist/style.css +676 -243
- package/dist/vg-print-vue2.es.js +5985 -31403
- package/package.json +6 -14
package/README.en.md
CHANGED
|
@@ -372,9 +372,9 @@ new Vue({
|
|
|
372
372
|
- `printView()` Browser print
|
|
373
373
|
- `print()` Direct print
|
|
374
374
|
- `toPdf()` Export PDF
|
|
375
|
-
- `
|
|
375
|
+
- `toPdf()` Export PDF with paper layout
|
|
376
376
|
- `toImage()` Export Image
|
|
377
|
-
- `
|
|
377
|
+
- `toImage()` Export Image with paper layout
|
|
378
378
|
- `toImage()` Export Image
|
|
379
379
|
- `setHiwebSocket(host, token, cb)` Set client address/token (Respects autoConnect state)
|
|
380
380
|
- `setHost(host, token, cb)` Set client address/token and connect immediately (Standard API)
|
|
@@ -437,10 +437,7 @@ exportPdf(tpl, printData, 'filename')
|
|
|
437
437
|
`exportPdf` / `exportImage` are lightweight wrappers around the template instance methods:
|
|
438
438
|
|
|
439
439
|
- `exportPdf(tpl, data, filename, options)` → `tpl.toPdf(data, filename, options)`
|
|
440
|
-
- `exportPdf2(tpl, data, filename, options)` → `tpl.toPdf2(data, filename, options)`
|
|
441
|
-
|
|
442
440
|
- `exportImage(tpl, data, options)` → `tpl.toImage(data, options)`
|
|
443
|
-
- `exportImage2(tpl, data, options)` → `tpl.toImage2(data, options)`
|
|
444
441
|
|
|
445
442
|
#### Export PDF
|
|
446
443
|
|
package/README.md
CHANGED
|
@@ -680,10 +680,8 @@ export default {
|
|
|
680
680
|
- `preView()` 打开预览弹窗;将当前模板与数据渲染为预览 HTML
|
|
681
681
|
- `printView()` 浏览器打印;不依赖客户端,调起系统打印对话框
|
|
682
682
|
- `print()` 直接打印;需客户端已连接,按当前选定打印机输出
|
|
683
|
-
- `toPdf()` 导出 PDF
|
|
684
|
-
- `
|
|
685
|
-
- `toImage()` 导出图片;使用内置 A4 排版示例参数导出
|
|
686
|
-
- `toImage2()` 导出图片;支持自定义参数,如缩放比例、页边距等(通过@zumer/snapdom库插件)
|
|
683
|
+
- `toPdf()` 导出 PDF;当前统一使用 `@zumer/snapdom` 渲染,支持缩放比例、页边距等参数
|
|
684
|
+
- `toImage()` 导出图片;当前统一使用 `@zumer/snapdom` 渲染,支持缩放比例、页边距等参数
|
|
687
685
|
|
|
688
686
|
- `setHiwebSocket(host: string, token?: string, cb?: Function)` 设置客户端地址与令牌并尝试重连;`cb(status, msg)` 为连接回调
|
|
689
687
|
- `connect(cb?: Function)` 主动连接客户端;`cb(status, msg)` 为连接回调
|
|
@@ -878,8 +876,8 @@ tpl.toPdf(this.printDataVar, '打印预览pdf', {
|
|
|
878
876
|
}
|
|
879
877
|
}
|
|
880
878
|
});
|
|
881
|
-
//
|
|
882
|
-
tpl.
|
|
879
|
+
// 当前 toPdf 内部统一使用 @zumer/snapdom 导出 PDF
|
|
880
|
+
tpl.toPdf(this.printDataVar, '打印预览pdf', {
|
|
883
881
|
onProgress: (cur, total) => {
|
|
884
882
|
// 导出进度100%的时候关闭等待
|
|
885
883
|
if (cur === total) {
|
|
@@ -924,8 +922,8 @@ tpl.toImage(this.printDataVar, {
|
|
|
924
922
|
}
|
|
925
923
|
})
|
|
926
924
|
|
|
927
|
-
//
|
|
928
|
-
tpl.
|
|
925
|
+
// 当前 toImage 内部统一使用 @zumer/snapdom 导出图片
|
|
926
|
+
tpl.toImage(this.printDataVar, {
|
|
929
927
|
paperWidth: 210,
|
|
930
928
|
paperHeight: 297,
|
|
931
929
|
limit: 6,
|
|
@@ -955,9 +953,7 @@ import {
|
|
|
955
953
|
getHtml,
|
|
956
954
|
printBrowser,
|
|
957
955
|
exportPdf,
|
|
958
|
-
exportPdf2,
|
|
959
956
|
exportImage,
|
|
960
|
-
exportImage2,
|
|
961
957
|
getPrinterList,
|
|
962
958
|
refreshPrinterList,
|
|
963
959
|
getAddress,
|
|
@@ -1020,7 +1016,7 @@ exportPdf(tpl, printData, '打印预览pdf', {
|
|
|
1020
1016
|
})
|
|
1021
1017
|
|
|
1022
1018
|
// 插件方法
|
|
1023
|
-
|
|
1019
|
+
exportPdf(tpl, printData, '打印预览pdf', {
|
|
1024
1020
|
paperWidth: 210,
|
|
1025
1021
|
paperHeight: 297,
|
|
1026
1022
|
perPage: 6,
|
|
@@ -1052,7 +1048,7 @@ await exportImage(tpl, printData, {
|
|
|
1052
1048
|
})
|
|
1053
1049
|
|
|
1054
1050
|
// 插件方法
|
|
1055
|
-
|
|
1051
|
+
exportImage(tpl, printData, {
|
|
1056
1052
|
paperWidth: 210,
|
|
1057
1053
|
paperHeight: 297,
|
|
1058
1054
|
limit: 6,
|
|
@@ -1125,14 +1121,9 @@ disconnect()
|
|
|
1125
1121
|
- 适用:报告类、A4/A5 正常分页模板。
|
|
1126
1122
|
|
|
1127
1123
|
```js
|
|
1128
|
-
// 不传 paperWidth/paperHeight,使用模板的面板尺寸与分页配置
|
|
1129
1124
|
exportPdf(tpl, printData, '打印预览pdf', {
|
|
1130
1125
|
onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
|
|
1131
1126
|
})
|
|
1132
|
-
|
|
1133
|
-
exportPdf2(tpl, printData, '打印预览pdf', {
|
|
1134
|
-
onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
|
|
1135
|
-
})
|
|
1136
1127
|
```
|
|
1137
1128
|
|
|
1138
1129
|
#### 模式 B:排版导出(把小模板拼到大纸张,例如 A4)
|
|
@@ -1155,20 +1146,6 @@ exportPdf(tpl, printData, '打印预览pdf', {
|
|
|
1155
1146
|
imageCompression: 'FAST', // 图片压缩算法 默认 FAST 支持 FAST、MEDIUM、SLOW
|
|
1156
1147
|
onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
|
|
1157
1148
|
})
|
|
1158
|
-
|
|
1159
|
-
exportPdf2(tpl, printData, '打印预览pdf', {
|
|
1160
|
-
paperWidth: 210, // mm
|
|
1161
|
-
paperHeight: 297, // mm
|
|
1162
|
-
perPage: 6, // 每页放 6 个(不够的到下一页)
|
|
1163
|
-
leftOffset: -1, // -1 表示水平居中;>=0 表示左边距 mm
|
|
1164
|
-
topOffset: -1, // -1 表示垂直居中;>=0 表示上边距 mm
|
|
1165
|
-
scale: 1, // 清晰度/性能权衡(也可用 pixelRatio)
|
|
1166
|
-
pdfCompress: true, // 是否压缩PDF 默认 true
|
|
1167
|
-
imageType: 'JPEG', // 图片类型 默认 JPEG 支持 JPEG、PNG
|
|
1168
|
-
imageQuality: 0.92, // 图片质量 0-1 默认 0.92
|
|
1169
|
-
imageCompression: 'FAST', // 图片压缩算法 默认 FAST 支持 FAST、MEDIUM、SLOW
|
|
1170
|
-
onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
|
|
1171
|
-
})
|
|
1172
1149
|
```
|
|
1173
1150
|
|
|
1174
1151
|
#### 排版规则(重点:perPage=0/不传的行为)
|