投影片與版面配置

FPresentation 管理投影片順序和共用頁面尺寸。FSlide 提供單張投影片解析後的頁面配置和背景。

管理投影片順序

TypeScript
const presentation = univerAPI.getActivePresentation()if (!presentation) {  throw new Error('No active presentation')}const agenda = presentation.appendSlide({ name: 'Agenda' })const summary = presentation.insertSlide(1, { name: 'Summary' })presentation.moveSlide(summary, 0)presentation.setActiveSlide(agenda)

使用 getSlides()、getSlideById() 和 getSlideByIndex() 讀取目前順序。deleteSlide() 會透過命令管線刪除投影片。

設定頁面尺寸

TypeScript
presentation.setPageSize({  preset: univerAPI.Enum.SlidePageSizePresetEnum.WideScreen16By9,})

slide.getPageLayout() 傳回解析後的頁面尺寸,以及元素邊界和順序。座標使用 Slides 模型座標系。

設定投影片背景

TypeScript
agenda.setBackground({  type: univerAPI.Enum.SlideBackgroundTypeEnum.Solid,  color: '#1d4ed8',})

傳入 undefined 可移除明確背景。setShowMasterBackground(false) 會隱藏該頁繼承的母片背景圖形,而不會從快照中刪除它們。

你覺得這篇文檔如何?

© 2026 DreamNum Co., Ltd.