vg-print 1.1.303 → 1.1.304

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 CHANGED
@@ -365,11 +365,8 @@ createApp(App).use(vgPrint).mount('#app')
365
365
  - `preView()` Open preview
366
366
  - `printView()` Browser print
367
367
  - `print()` Direct print
368
- - `toPdf()` Export PDF
369
- - `toPdf2()` Export PDF with paper layout
370
- - `toImage()` Export Image
371
- - `toImage2()` Export Image with paper layout
372
- - `toImage()` Export Image
368
+ - `toPdf()` Export PDF with the `@zumer/snapdom` pipeline, including paper layout options
369
+ - `toImage()` Export image with the `@zumer/snapdom` pipeline, including paper layout options
373
370
  - `setHiwebSocket(host, token, cb)` Set client address/token (Respects autoConnect state)
374
371
  - `setHost(host, token, cb)` Set client address/token and connect immediately (Standard API)
375
372
  - `connect(cb)` Connect to client
@@ -431,10 +428,8 @@ exportPdf(tpl, printData, 'filename')
431
428
  `exportPdf` / `exportImage` are lightweight wrappers around the template instance methods:
432
429
 
433
430
  - `exportPdf(tpl, data, filename, options)` → `tpl.toPdf(data, filename, options)`
434
- - `exportPdf2(tpl, data, filename, options)` → `tpl.toPdf2(data, filename, options)`
435
431
 
436
432
  - `exportImage(tpl, data, options)` → `tpl.toImage(data, options)`
437
- - `exportImage2(tpl, data, options)` → `tpl.toImage2(data, options)`
438
433
 
439
434
  #### Export PDF
440
435
 
package/README.md CHANGED
@@ -635,10 +635,8 @@ const disableAutoConnect = () => designer.value.disAutoConnect()
635
635
  - `preView()` 打开预览弹窗;将当前模板与数据渲染为预览 HTML
636
636
  - `printView()` 浏览器打印;不依赖客户端,调起系统打印对话框
637
637
  - `print()` 直接打印;需客户端已连接,按当前选定打印机输出
638
- - `toPdf()` 导出 PDF;使用内置 A4 排版示例参数导出
639
- - `toPdf2()` 导出 PDF;支持自定义参数,如缩放比例、页边距等(通过@zumer/snapdom库插件)
640
- - `toImage()` 导出图片;使用内置 A4 排版示例参数导出
641
- - `toImage2()` 导出图片;支持自定义参数,如缩放比例、页边距等(通过@zumer/snapdom库插件)
638
+ - `toPdf()` 导出 PDF;使用基于 `@zumer/snapdom` 的导出链路,支持缩放比例、页边距、纸张排版等参数
639
+ - `toImage()` 导出图片;使用基于 `@zumer/snapdom` 的导出链路,支持缩放比例、页边距、纸张排版等参数
642
640
  - `setHiwebSocket(host: string, token?: string, cb?: Function)` 设置客户端地址与令牌并尝试重连;`cb(status, msg)` 为连接回调
643
641
  - `connect(cb?: Function)` 主动连接客户端;`cb(status, msg)` 为连接回调
644
642
  - `disconnect()` 断开客户端连接
@@ -834,8 +832,8 @@ tpl.toPdf(this.printDataVar, '打印预览pdf', {
834
832
  }
835
833
  }
836
834
  });
837
- // 这是使用@zumer/snapdom库插件导出PDF的示例,使用方式和toPdf一样
838
- tpl.toPdf2(this.printDataVar, '打印预览pdf', {
835
+ // 使用当前保留的 toPdf 导出链路(基于 @zumer/snapdom
836
+ tpl.toPdf(this.printDataVar, '打印预览pdf', {
839
837
  onProgress: (cur, total) => {
840
838
  // 导出进度100%的时候关闭等待
841
839
  if (cur === total) {
@@ -880,8 +878,8 @@ tpl.toImage(this.printDataVar, {
880
878
  }
881
879
  })
882
880
 
883
- // 这是使用@zumer/snapdom库插件导出图片的示例,使用方式和oImage一样
884
- tpl.toImage2(this.printDataVar, {
881
+ // 使用当前保留的 toImage 导出链路(基于 @zumer/snapdom
882
+ tpl.toImage(this.printDataVar, {
885
883
  paperWidth: 210,
886
884
  paperHeight: 297,
887
885
  limit: 6,
@@ -911,9 +909,7 @@ import {
911
909
  getHtml,
912
910
  printBrowser,
913
911
  exportPdf,
914
- exportPdf2,
915
912
  exportImage,
916
- exportImage2,
917
913
  getPrinterList,
918
914
  refreshPrinterList,
919
915
  getAddress,
@@ -975,23 +971,6 @@ exportPdf(tpl, printData, '打印预览pdf', {
975
971
  }
976
972
  })
977
973
 
978
- // 插件方法
979
- exportPdf2(tpl, printData, '打印预览pdf', {
980
- paperWidth: 210,
981
- paperHeight: 297,
982
- perPage: 6,
983
- leftOffset:-1,
984
- topOffset:-1,
985
- scale: 1, // 清晰度/性能权衡(也可用 pixelRatio) 1:100% 2:200% 3:300%
986
- pdfCompress: true, // 是否压缩PDF 默认 true
987
- imageType: 'JPEG', // 图片类型 默认 JPEG 支持 JPEG、PNG
988
- imageQuality: 0.92, // 图片质量 0-1 默认 0.92
989
- imageCompression: 'FAST', // 图片压缩算法 默认 FAST 支持 FAST、MEDIUM、SLOW
990
- onProgress: (cur: number, total: number) => {
991
- console.log('toPdf 进度', Math.floor((cur/total)*100))
992
- }
993
- })
994
-
995
974
  // 原生方法
996
975
  await exportImage(tpl, printData, {
997
976
  isDownload: true,
@@ -1007,20 +986,6 @@ await exportImage(tpl, printData, {
1007
986
  }
1008
987
  })
1009
988
 
1010
- // 插件方法
1011
- exportImage2(tpl, printData, {
1012
- paperWidth: 210,
1013
- paperHeight: 297,
1014
- limit: 6,
1015
- isDownload: true,
1016
- name: 'A4排版',
1017
- type: 'image/jpeg',
1018
- pixelRatio: 2,
1019
- onProgress: (cur: number, total: number) => {
1020
- console.log('toImage 进度', Math.floor((cur/total)*100))
1021
- }
1022
- })
1023
-
1024
989
  // 6) 客户端直连打印(需要本地客户端)
1025
990
  setHiwebSocket('http://127.0.0.1:17521', 'your-token') // 遵循 autoConnect 状态
1026
991
  // 或者使用标准 API(设置即连接)
@@ -1093,10 +1058,6 @@ disconnect()
1093
1058
  exportPdf(tpl, printData, '打印预览pdf', {
1094
1059
  onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
1095
1060
  })
1096
-
1097
- exportPdf2(tpl, printData, '打印预览pdf', {
1098
- onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
1099
- })
1100
1061
  ```
1101
1062
 
1102
1063
  #### 模式 B:排版导出(把小模板拼到大纸张,例如 A4)
@@ -1119,18 +1080,6 @@ exportPdf(tpl, printData, '打印预览pdf', {
1119
1080
  imageCompression: 'FAST', // 图片压缩算法 默认 FAST 支持 FAST、MEDIUM、SLOW
1120
1081
  onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
1121
1082
  })
1122
-
1123
- exportPdf2(tpl, printData, '打印预览pdf', {
1124
- paperWidth: 210, // mm
1125
- paperHeight: 297, // mm
1126
- perPage: 6, // 每页放 6 个(不够的到下一页)
1127
- leftOffset: -1, // -1 表示水平居中;>=0 表示左边距 mm
1128
- topOffset: -1, // -1 表示垂直居中;>=0 表示上边距 mm
1129
- scale: 1, // 清晰度/性能权衡(也可用 pixelRatio)
1130
- pdfCompress: true, // 是否压缩PDF 默认 true
1131
- imageType: 'JPEG', // 图片类型 默认 JPEG 支持 JPEG、PNG
1132
- imageQuality: 0.92, // 图片质量 0-1 默认 0.92
1133
- imageCompression: 'FAST', // 图片压缩算法 默认 FAST 支持 FAST、MEDIUM、SLOW
1134
1083
  onProgress: (cur, total) => console.log('toPdf 进度', Math.floor((cur / total) * 100))
1135
1084
  })
1136
1085
  ```
@@ -1321,4 +1270,3 @@ const onSave = ({ template, data, templateId }) => {
1321
1270
  }
1322
1271
  </script>
1323
1272
  ```
1324
-