PPTX
演示文稿属性
配置演示文稿级别设置、视图属性、相册和修改保护
演示文稿设置
设置演示文稿的根属性(服务器缩放、起始幻灯片编号、RTL 等):
{
"firstSlideNum": 1,
"rtl": false,
"autoCompressPictures": true,
"bookmarkIdSeed": 1234,
"slides": [
{
"children": [
{ "shape": { "textBody": { "children": ["Presentation with custom settings"] } } }
]
}
]
}
import { Presentation, Shape, Packer } from "@office-open/pptx";
const pres = new Presentation({
firstSlideNum: 1,
rtl: false,
autoCompressPictures: true,
bookmarkIdSeed: 1234,
slides: [
{
children: [
new Shape({
textBody: { text: "Presentation with custom settings" },
}),
],
},
],
});
根属性
| 选项 | 类型 | 说明 |
|---|---|---|
serverZoom | string | 服务器缩放级别 |
firstSlideNum | number | 起始幻灯片编号 |
showSpecialPlsOnTitleSld | boolean | 在标题幻灯片上显示占位符 |
rtl | boolean | 从右到左布局 |
removePersonalInfoOnSave | boolean | 保存时移除个人信息 |
compatMode | boolean | 兼容模式 |
strictFirstAndLastChars | boolean | 严格的首尾字符规则 |
embedTrueTypeFonts | boolean | 嵌入 TrueType 字体 |
saveSubsetFonts | boolean | 保存字体子集 |
autoCompressPictures | boolean | 自动压缩图片 |
bookmarkIdSeed | number | 书签 ID 种子 |
conformance | string | "strict" 或 "transitional" |
修改保护
使用密码保护演示文稿免受修改。当提供 password 时,会自动计算 SHA-512 哈希(随机盐值,100,000 次迭代):
{
"modifyVerifier": {
"password": "secret"
},
"slides": [
{
"children": [{ "shape": { "textBody": { "children": ["Protected presentation"] } } }]
}
]
}
const pres = new Presentation({
modifyVerifier: {
password: "secret",
},
slides: [
{
children: [
new Shape({
textBody: { text: "Protected presentation" },
}),
],
},
],
});
修改验证选项
| 选项 | 类型 | 说明 |
|---|---|---|
password | string | 明文密码(自动哈希) |
algorithmName | string | 哈希算法(默认:"SHA-512") |
hashValue | string | Base64 编码的密码哈希 |
saltValue | string | Base64 编码的盐值 |
spinValue | number | Spin 值 |
spinCount | number | 哈希迭代次数 |
cryptoProviderType | string | 加密提供程序类型 |
cryptoAlgorithmClass | string | 算法类别 |
cryptoAlgorithmType | string | 算法类型 |
cryptoAlgorithmSid | number | 算法 SID |
cryptoProvider | string | 加密提供程序 |
saltData | string | Base64 编码的盐数据 |
hashData | string | Base64 编码的哈希数据 |
algorithmExtensionId | number | 算法扩展 ID |
algorithmExtensionSource | string | 算法扩展来源 |
cryptoProviderTypeExtension | number | 加密提供程序类型扩展 |
cryptoProviderTypeExtensionSource | string | 加密提供程序类型扩展来源 |
视图属性
配置演示文稿打开时的显示方式:
{
"view": {
"lastView": "slideView",
"showComments": true,
"gridSpacing": { "cx": 50800, "cy": 50800 }
},
"slides": [
{
"children": [{ "shape": { "textBody": { "children": ["Slide with view settings"] } } }]
}
]
}
const pres = new Presentation({
view: {
lastView: "slideView",
showComments: true,
gridSpacing: { cx: 50800, cy: 50800 },
},
slides: [
{
children: [new Shape({ textBody: { text: "Slide with view settings" } })],
},
],
});
视图选项
| 选项 | 类型 | 说明 |
|---|---|---|
lastView | string | 上次活动视图("slideView"、"slideMasterView"、"notesView"、"handoutView"、"outlineView"、"slideSorterView") |
showComments | boolean | 显示批注 |
gridSpacing | object | 网格间距 { cx, cy },单位为 EMU |
zoomScaleNumerator | number | 缩放比例分子 |
zoomScaleDenominator | number | 缩放比例分母 |
normalView | object | 普通视图设置 |
slideView | object | 幻灯片视图设置 |
普通视图选项
| 选项 | 类型 | 说明 |
|---|---|---|
showOutlineIcons | boolean | 显示大纲图标 |
snapVertSplitter | boolean | 对齐垂直分隔条 |
vertBarState | string | "restored"、"maximized" 或 "minimized" |
horzBarState | string | "restored"、"maximized" 或 "minimized" |
preferSingleView | boolean | 首选单视图 |
幻灯片视图选项
| 选项 | 类型 | 说明 |
|---|---|---|
snapToGrid | boolean | 对齐网格 |
snapToObjects | boolean | 对齐对象 |
showGuides | boolean | 显示参考线 |
varScale | boolean | 可变缩放 |
放映、Web 和打印属性
配置幻灯片放映、Web 发布和打印设置:
{
"show": {
"type": "present",
"showNarration": true,
"useTimings": true
},
"web": {
"showAnimation": true,
"resizeGraphics": true
},
"print": {
"printWhat": "handouts4",
"colorMode": "color"
},
"slides": [
{
"children": [{ "shape": { "textBody": { "children": ["Full presentation properties"] } } }]
}
]
}
const pres = new Presentation({
show: {
type: "present",
showNarration: true,
useTimings: true,
},
web: {
showAnimation: true,
resizeGraphics: true,
},
print: {
printWhat: "handouts4",
colorMode: "color",
},
slides: [
{
children: [new Shape({ textBody: { text: "Full presentation properties" } })],
},
],
});
放映选项
| 选项 | 类型 | 说明 |
|---|---|---|
type | string | "present"、"kiosk" 或 "browse" |
loop | boolean | 循环放映 |
showScrollbar | boolean | 浏览模式下显示滚动条 |
slideRange | object | 幻灯片范围 { start, end }(从 1 开始) |
restart | number | 展台模式自动重启超时(毫秒) |
showNarration | boolean | 放映时播放旁白 |
showAnimation | boolean | 放映时播放动画 |
useTimings | boolean | 使用录制的排练时间 |
penColor | string | 激光笔颜色(十六进制) |
Web 选项
| 选项 | 类型 | 说明 |
|---|---|---|
showAnimation | boolean | 在 Web 中显示动画 |
resizeGraphics | boolean | 调整图形大小 |
allowPng | boolean | 允许 PNG 图片 |
relyOnVml | boolean | 依赖 VML |
organizeInFolders | boolean | 按文件夹组织 |
useLongFilenames | boolean | 使用长文件名 |
imageSize | string | 图片大小 |
encoding | string | 字符编码 |
color | string | 颜色模式 |
打印选项
| 选项 | 类型 | 说明 |
|---|---|---|
printWhat | string | 打印内容("slides"、"handouts1"、"handouts2"、"handouts3"、"handouts4"、"handouts6"、"handouts9"、"notes"、"outline") |
colorMode | string | "color"、"gray" 或 "blackWhite" |
hiddenSlides | boolean | 打印隐藏的幻灯片 |
scaleToFitPaper | boolean | 缩放以适应纸张 |
frameSlides | boolean | 给幻灯片加边框 |
HTML 发布
配置 HTML 发布属性,用于 Web 输出:
{
"htmlPublish": {
"showSpeakerNotes": true,
"title": "Published Slides",
"rId": "rId1"
},
"slides": [
{
"children": [{ "shape": { "textBody": { "children": ["HTML publish demo"] } } }]
}
]
}
const pres = new Presentation({
htmlPublish: {
showSpeakerNotes: true,
title: "Published Slides",
rId: "rId1",
},
slides: [
{
children: [new Shape({ textBody: { text: "HTML publish demo" } })],
},
],
});
HTML 发布选项
| 选项 | 类型 | 说明 |
|---|---|---|
showSpeakerNotes | boolean | 包含演讲者备注 |
title | string | 发布的演示文稿标题 |
rId | string | 关系 ID |
相册
创建相册演示文稿,支持布局和边框选项:
{
"photoAlbum": {
"showCaptions": true,
"layout": "2pic",
"frame": "frameStyle1"
},
"slides": [
{
"children": [{ "shape": { "textBody": { "children": ["Photo Album"] } } }]
}
]
}
const pres = new Presentation({
photoAlbum: {
showCaptions: true,
layout: "2pic",
frame: "frameStyle1",
},
slides: [
{
children: [new Shape({ textBody: { text: "Photo Album" } })],
},
],
});
相册选项
| 选项 | 类型 | 说明 |
|---|---|---|
blackWhite | boolean | 黑白模式 |
showCaptions | boolean | 在图片下方显示标题 |
layout | string | "fitToSlide"、"1pic"、"2pic"、"4pic"、"1picTitle"、"2picTitle"、"4picTitle" |
frame | string | "frameStyle1" 到 "frameStyle7",或 "none" |