Step 1 — Knowledge base: perfect all reference/*.md with type, range, default, unit - text.md: add DataOrPathProps, path/data, bullet deprecated params - chart.md: add deprecated section, fix 19 params with missing elements - slide.md: add bkgd→background deprecated mapping - output.md: add masterSlide, presLayout Step 2 — Schema: align schema/presentation.schema.json with KB - Add catAxisItem and valAxisItem definitions with full sub-property constraints - Fix 7 enum constraints (barDir, displayBlanksAs, bar3DShape, etc.) - Add 4 missing fields (verbose, autoPageCharWeight, autoPageLineWeight, notes, masterSlide, presLayout) Step 3 — Translation engine: transform renderers from passthrough to validation - index.js: add normalizePosition, normalizeColor, validateEnum shared utilities - All renderers: position validation, color hex normalization, enum validation - Image: graceful failure handling (catch load errors, warn, continue) - Chart: chartType enum validation, data parity check - Table: colspan/rowspan integer validation, border array check - Full verification: basic.json and full.json generate valid PPTX Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3.9 KiB
3.9 KiB
输出参数 (Output Props)
输出参数用于导出演示文稿,支持 writeFile()(写入文件)、write()(返回数据)和 stream()(返回流)三种方式。
输出方法
pptx.writeFile()
pptx.writeFile(props?: WriteFileProps): Promise<string>
-
fileName:导出文件名
- 类型:
string - 默认值:
'Presentation.pptx'
- 类型:
-
compression:是否启用压缩
- 类型:
boolean - 默认值:
false - 说明:可显著减小文件体积,但导出耗时略长
- 始于:v3.5.0
- 类型:
pptx.write()
pptx.write(props?: WriteProps): Promise<string | ArrayBuffer | Blob | Uint8Array>
-
outputType:输出类型
- 类型:
WRITE_OUTPUT_TYPE - 取值范围:
'arraybuffer' | 'base64' | 'binarystring' | 'blob' | 'nodebuffer' | 'uint8array' | 'STREAM' - 默认值:
'blob'
- 类型:
-
compression:是否启用压缩
- 类型:
boolean - 默认值:
false - 始于:v3.5.0
- 类型:
pptx.stream()
pptx.stream(props?: WriteBaseProps): Promise<string | ArrayBuffer | Blob | Uint8Array>
- compression:是否启用压缩
- 类型:
boolean - 默认值:
false - 始于:v3.5.0
- 类型:
WriteBaseProps
writeFile() 和 stream() 的输出基础属性。
- compression:压缩选项
- 类型:
boolean - 默认值:
false - 始于:v3.5.0
- 说明:启用 Zip 压缩以减小文件体积
- 类型:
WriteProps
继承 WriteBaseProps,用于 write() 方法。
-
outputType:输出类型
- 类型:
WRITE_OUTPUT_TYPE - 取值范围:
'arraybuffer' | 'base64' | 'binarystring' | 'blob' | 'nodebuffer' | 'uint8array' | 'STREAM' - 默认值:
'blob'
- 类型:
-
compression:压缩选项
- 类型:
boolean - 默认值:
false
- 类型:
WriteFileProps
继承 WriteBaseProps,用于 writeFile() 方法。
-
fileName:导出文件名
- 类型:
string - 默认值:
'Presentation.pptx'
- 类型:
-
compression:压缩选项
- 类型:
boolean - 默认值:
false
- 类型:
OutputType 枚举
| 常量 | 值 | 说明 |
|---|---|---|
OutputType.arraybuffer |
'arraybuffer' |
ArrayBuffer |
OutputType.base64 |
'base64' |
Base64 字符串 |
OutputType.binarystring |
'binarystring' |
二进制字符串 |
OutputType.blob |
'blob' |
Blob 对象(默认) |
OutputType.nodebuffer |
'nodebuffer' |
Node.js Buffer |
OutputType.uint8array |
'uint8array' |
Uint8Array |
JSZIP_OUTPUT_TYPE
type JSZIP_OUTPUT_TYPE = 'arraybuffer' | 'base64' | 'binarystring' | 'blob' | 'nodebuffer' | 'uint8array'
WRITE_OUTPUT_TYPE
type WRITE_OUTPUT_TYPE = JSZIP_OUTPUT_TYPE | 'STREAM'
Presentation 属性
导出前的演示文稿元数据属性。
-
author:作者
- 类型:
string - 说明:演示文稿作者名称
- 类型:
-
company:公司
- 类型:
string - 说明:公司名称
- 类型:
-
layout:布局名称
- 类型:
string - 说明:当前演示文稿布局
- 标准值:
'LAYOUT_4x3'、'LAYOUT_16x9'、'LAYOUT_16x10'、'LAYOUT_WIDE'
- 类型:
-
rtlMode:从右向左模式
- 类型:
boolean - 默认值:
false
- 类型:
-
revision:修订号
- 类型:
string - 说明:必须为整数(不含小数点或逗号),否则 PowerPoint 打开时会报错
- 类型:
-
subject:主题
- 类型:
string - 说明:演示文稿主题
- 类型:
-
theme:主题字体
- 类型:
ThemeProps - 子参数:
- theme.headFontFace:标题字体(默认
'Calibri Light') - theme.bodyFontFace:正文字体(默认
'Calibri')
- theme.headFontFace:标题字体(默认
- 类型:
-
title:演示文稿标题
- 类型:
string
- 类型:
-
masterSlide:当前母版
- 类型:
PresSlide - 说明:当前演示文稿的母版幻灯片对象
- 类型:
-
presLayout:布局信息
- 类型:
PresLayout - 说明:只读,包含
name(布局名称)、width(宽度,英寸)、height(高度,英寸)
- 类型: