vg-print-vue2 1.0.522 → 1.0.601

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
@@ -86,6 +86,30 @@ hiprint.register({
86
86
  { content: 'vg-print', timestamp: true }
87
87
  ```
88
88
 
89
+ ### 可选 PDF 导出插件
90
+
91
+ PDF 导出已从核心库拆分,Vue 2 与 Vue 3 共用 `@vg-print/plugin-api-pdf`,注册方式相同:
92
+
93
+ ```bash
94
+ npm install @vg-print/plugin-api-pdf
95
+ ```
96
+
97
+ ```js
98
+ import { hiprint, createTemplate } from 'vg-print-vue2'
99
+ import pluginApiPdf from '@vg-print/plugin-api-pdf'
100
+
101
+ // 在挂载设计器/预览组件前注册,可与其他插件放在同一个 plugins 数组。
102
+ async function exportReport(templateJson, printData, pdfOptions = {}) {
103
+ await hiprint.register({ plugins: [pluginApiPdf()] })
104
+ const template = createTemplate(templateJson)
105
+ return template.toPdf(printData, '报告.pdf', pdfOptions)
106
+ }
107
+ ```
108
+
109
+ 原 `template.toPdf(data, name, options)`、`exportPdf()` 的参数、分页、标签拼版及返回值保持一致;例如 `isDownload: false, type: 'blob'` 可返回 PDF 数据。`clientGenerate()` 需要先生成 PDF,所以也必须注册该插件。
110
+
111
+ 未注入时,Preview 和 Header 的 PDF 按钮自动隐藏;Preview 的 `showPdf` / `show({ showPdf })` 及 Header 的 `showPdf` 仍可主动隐藏按钮。直接调用导出入口会提示缺少插件。库入口不内置插件,示例入口已注册;图片导出继续由核心提供。
112
+
89
113
  ## 静默打印客户端工具安装包
90
114
 
91
115
  [客户端工具下载](https://download.csdn.net/download/github_38400706/92538739)
@@ -556,6 +580,7 @@ import 'vg-print-vue2/style.css'
556
580
  - `showHeader: boolean` 是否显示顶部 Header,默认 `true`
557
581
  - `showToolbar: boolean` 是否显示二级工具栏 Toolbar,默认 `true`
558
582
  - `showFooter: boolean` 是否显示底部 Footer,默认 `true`
583
+ - `showTemplateLibrary: boolean` 是否显示左侧模板库页签及内容,默认 `true`;设为 `false` 时仅保留组件库,不影响模板加载和保存功能;动态关闭时自动切回组件库
559
584
  - `footer-text: string` 底部默认文案(仅在未提供 `#footer` 插槽时展示)
560
585
 
561
586
  以上属性支持运行时动态修改;组件内部已监听并应用。
@@ -568,7 +593,7 @@ import 'vg-print-vue2/style.css'
568
593
  :config="{ showAdsorbLine: true, showPosition: true, showSizeBox: true }"
569
594
  :design-options="{ grid: true, activePanel: true, adaptToSize: true }"
570
595
  theme="light"
571
- :show-option="{ showHeader: true, showToolbar: true, showFooter: true }"
596
+ :show-option="{ showHeader: true, showToolbar: true, showFooter: true, showTemplateLibrary: false }"
572
597
  footer-text="联系我:xxxx(这里可写联系信息)"
573
598
  />
574
599
  </template>
@@ -1148,6 +1173,8 @@ disconnect()
1148
1173
 
1149
1174
  > `exportPdf(tpl, data, filename, options)` 本质调用的是模板实例的 `tpl.toPdf(data, filename, options)`;两者参数一致。
1150
1175
 
1176
+ 需先安装并通过 `hiprint.register({ plugins: [pluginApiPdf()] })` 注册 `@vg-print/plugin-api-pdf`,参见前面的“可选 PDF 导出插件”。以下参数继续沿用原有导出实现。
1177
+
1151
1178
  #### 模式 A:普通导出(按模板自身纸张与分页)
1152
1179
 
1153
1180
  - 特点:不传纸张宽高,导出结果与预览分页一致(每个 `.hiprint-printPaper` 一页)。