vg-print 1.1.317 → 1.1.319

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
@@ -1007,7 +1007,7 @@ const preview = async () => {
1007
1007
  await nextTick() // 等容器渲染出来
1008
1008
 
1009
1009
  const tpl = createTemplate(tmplJson)
1010
- const html = getHtml(tpl, printData) // 始终为字符串
1010
+ const html = await getHtml(tpl, printData) // 建议始终 await(兼容 beforeGetHtml 返回 Promise)
1011
1011
 
1012
1012
  const container = document.getElementById('preview_content_custom') // 显示内容的div的id
1013
1013
  if (!container) {
@@ -1017,6 +1017,45 @@ const preview = async () => {
1017
1017
  container.innerHTML = html
1018
1018
  }
1019
1019
 
1020
+ #### beforeGetHtml(获取 HTML 前处理)
1021
+
1022
+ 用于在生成 HTML 后、返回/打印/直连发送前,对 HTML 字符串做二次处理;支持返回 Promise。
1023
+
1024
+ 回调签名:
1025
+
1026
+ ```js
1027
+ beforeGetHtml: ({ template, html }) => html
1028
+ ```
1029
+
1030
+ - `template`:当前 `hiprint.PrintTemplate` 实例
1031
+ - `html`:生成的 HTML 字符串(可返回新字符串替换;返回 `undefined/null` 则保持不变)
1032
+
1033
+ 示例:
1034
+
1035
+ ```js
1036
+ const tpl = createTemplate(tmplJson)
1037
+
1038
+ const html = await getHtml(tpl, printData, {
1039
+ beforeGetHtml: async ({ template, html }) => {
1040
+ return html
1041
+ }
1042
+ })
1043
+
1044
+ await tpl.getHtml(printData, {
1045
+ beforeGetHtml: ({ template, html }) => html
1046
+ })
1047
+
1048
+ printBrowser(tpl, printData, {
1049
+ beforeGetHtml: ({ template, html }) => html
1050
+ })
1051
+
1052
+ tpl.print2(printData, {
1053
+ printer: printers?.[0]?.name || '',
1054
+ title: '打印预览pdf',
1055
+ beforeGetHtml: ({ template, html }) => html
1056
+ })
1057
+ ```
1058
+
1020
1059
  // 3) 浏览器打印(不需要客户端)
1021
1060
  printBrowser(tpl, printData)
1022
1061
 
@@ -1347,3 +1386,19 @@ const onSave = ({ template, data, templateId }) => {
1347
1386
  }
1348
1387
  </script>
1349
1388
  ```
1389
+
1390
+ ## License
1391
+
1392
+ LGPL
1393
+
1394
+ ### 开源使用须知
1395
+
1396
+ 1. 请自觉遵守 LGPL 协议,其他用途可联系作者;
1397
+
1398
+ 2. 允许用于个人学习、毕业设计、教学案例、公益事业、商业使用;
1399
+
1400
+ 3. 如果商用必须保留版权信息,请自觉遵守;
1401
+
1402
+ 4. 禁止将本开源的代码和资源进行任何形式任何名义的出售,否则产生的一切任何后果责任由侵权者自负;
1403
+
1404
+ 5. 商用请仔细审查代码和漏洞,不得用于任一国家许可范围之外的商业应用,产生的一切任何后果责任自负;
@@ -1,5 +1,13 @@
1
1
 
2
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
+ }
3
11
  body {
4
12
  margin: 0px;
5
13
  padding: 0px;
@@ -29,6 +37,8 @@
29
37
  position: relative;
30
38
  padding: 0 0 0 0;
31
39
  page-break-after: always;
40
+ break-after: page;
41
+ break-inside: avoid;
32
42
  -webkit-user-select: none; /* Chrome/Safari/Opera */
33
43
  -moz-user-select: none; /* Firefox */
34
44
  user-select: none;