投影片與版面配置

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.