# FPresentation

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/presentation](https://docs.univer.ai/zh-CN/reference/facade/presentation)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/presentation.md](https://docs.univer.ai/zh-CN/reference/facade/presentation.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/presentation.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/presentation.mdx)

---

The facade class for a presentation.

## Access

Access through:

* [`FUniver.createPresentation()`](https://docs.univer.ai/zh-CN/reference/facade/univer.md#createpresentation)
* [`FUniver.getActivePresentation()`](https://docs.univer.ai/zh-CN/reference/facade/univer.md#getactivepresentation)
* [`FUniver.getPresentation()`](https://docs.univer.ai/zh-CN/reference/facade/univer.md#getpresentation)
* [`FUniver.getSlideCommandTarget()`](https://docs.univer.ai/zh-CN/reference/facade/univer.md#getslidecommandtarget)
* [`FCollaboration.loadSlideAsync()`](https://docs.univer.ai/zh-CN/reference/facade/collaboration.md#loadslideasync)

## Setup

Register [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) or a preset that includes it. In plugin mode, import `@univerjs-pro/slides/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/slides/getting-started/facade.md).

## `@univerjs-pro/slides`

### `FPresentation.appendSlide`

Append a new slide to the end of the presentation.

```typescript
appendSlide(options?: Partial<ISlidePage>): FSlide
```

**Parameters**

* `options` — Optional. Default: `{}`. The slide creation options.

**Returns**

The created slide.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const slide = fPresentation.appendSlide({ name: 'Summary' })
console.log(slide)
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md) · [`Partial`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts) · [`ISlidePage`](https://docs.univer.ai/zh-CN/reference/types/slide-page.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.applyTransitionToAll`

Apply a slide transition to all slides that currently exist in the presentation.

The transition is visible during slide playback when moving between slides. Slides added
after this call are not automatically assigned this transition; call this method again if
newly added slides should use the same transition.

```typescript
applyTransitionToAll(transition: ISlideTransition): this
```

**Parameters**

* `transition` — Required. The slide transition to apply.

**Returns**

This presentation, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
fPresentation.applyTransitionToAll({
  type: univerAPI.Enum.SlideTransitionTypeEnum.Push,
  duration: 1000,
  direction: univerAPI.Enum.SlideTransitionDirectionEnum.Right,
})
```

**Types:** [`ISlideTransition`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.clearPresentationBackgroundGraphics`

Clear managed presentation background graphics.

```typescript
clearPresentationBackgroundGraphics(options?: ISetPresentationBackgroundGraphicsOptions): this
```

**Parameters**

* `options` — Optional. Target master options.

**Returns**

This presentation, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
fPresentation.clearPresentationBackgroundGraphics({
  target: univerAPI.Enum.SlidePresentationBackgroundGraphicsTargetEnum.ActiveMaster,
})
```

**Types:** [`ISetPresentationBackgroundGraphicsOptions`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.deleteSlide`

Delete a slide.

```typescript
deleteSlide(slide: FSlide): boolean
```

**Parameters**

* `slide` — Required. The slide facade or slide id to delete.

**Returns**

Whether the slide was deleted successfully.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const slide = fPresentation.getSlideByIndex(1)
if (slide) {
  fPresentation.deleteSlide(slide)
}
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getActiveSlide`

Get the active slide.

```typescript
getActiveSlide(): FSlide | null
```

**Returns**

The active slide, or `null` if no slide is active.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const activeSlide = fPresentation.getActiveSlide()
console.log(activeSlide)
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getId`

Get the presentation id.

```typescript
getId(): string
```

**Returns**

The presentation id.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
console.log(fPresentation.getId())
```

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getMasterElementPermission`

Returns an Element permission facade for a Master or Layout page.

```typescript
getMasterElementPermission(sourcePageType: PageTypeEnum.Master | PageTypeEnum.Layout, pageId: string, elementId: string): FSlideObjectPermission
```

**Parameters**

* `sourcePageType` — Required. Whether the element belongs to a Master or Layout page.
* `pageId` — Required. Stable source page id.
* `elementId` — Required. Stable element id.

**Returns**

Permission facade combining Presentation, Master View, and Element Edit points.

**Examples**

```ts
import { PageTypeEnum } from '@univerjs-pro/slides'

const presentation = univerAPI.getActivePresentation()
if (!presentation) throw new Error('No active Presentation.')
const master = Object.values(presentation.save().masterPages ?? {})[0]
const elementId = master?.elementOrder[0]
if (!master || !elementId) throw new Error('Master element not found.')
await presentation
  .getMasterElementPermission(PageTypeEnum.Master, master.id, elementId)
  .setReadOnly()
```

**Types:** [`FSlideObjectPermission`](https://docs.univer.ai/zh-CN/reference/facade/slide-object-permission.md) · [`PageTypeEnum.Master`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.enum.d.ts) · [`PageTypeEnum.Layout`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.enum.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getMasterViewPermission`

Returns the shared Master and Layout edit permission facade.

```typescript
getMasterViewPermission(): FSlideObjectPermission
```

**Returns**

Permission facade combining Presentation and Master View Edit points.

**Examples**

```ts
const presentation = univerAPI.getActivePresentation()
if (!presentation) throw new Error('No active Presentation.')
await presentation.getMasterViewPermission().setReadOnly()
```

**Types:** [`FSlideObjectPermission`](https://docs.univer.ai/zh-CN/reference/facade/slide-object-permission.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getName`

Get the presentation name.

```typescript
getName(): string
```

**Returns**

The presentation name.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
console.log(fPresentation.getName())
```

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getPageSize`

Get the default page size of the presentation.

```typescript
getPageSize(): ISlidePageSize
```

**Returns**

The page size.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
console.log(fPresentation.getPageSize())
```

**Types:** [`ISlidePageSize`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getPermission`

Returns the Presentation unit permission facade.

```typescript
getPermission(): FPresentationPermission
```

**Returns**

Permission facade for Edit, Copy, Print, Export, and Comment.

**Examples**

```ts
const presentation = univerAPI.getActivePresentation()
if (!presentation) throw new Error('No active Presentation.')
await presentation.getPermission().setReadOnly()
```

**Types:** [`FPresentationPermission`](https://docs.univer.ai/zh-CN/reference/facade/presentation-permission.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getPresentation`

Get the underlying presentation model.

```typescript
getPresentation(): SlideModel
```

**Returns**

The presentation model.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const model = fPresentation.getPresentation()
console.log(model)
```

**Types:** [`SlideModel`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/models/slide-model.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getPresentationBackgroundGraphics`

Get managed presentation background graphics from a master page.
When `masterPageId` is omitted, the active slide's master is used.

```typescript
getPresentationBackgroundGraphics(masterPageId?: string): ISlidePresentationBackgroundGraphic[]
```

**Parameters**

* `masterPageId` — Optional. Optional master page id to read from.

**Returns**

The managed deck background graphics.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const graphics = fPresentation.getPresentationBackgroundGraphics()
console.log(graphics)
```

**Types:** [`ISlidePresentationBackgroundGraphic`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getSlideById`

Get a slide by id.

```typescript
getSlideById(id: string): FSlide | null
```

**Parameters**

* `id` — Required. The slide id.

**Returns**

The slide, or `null` if it does not exist.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const slide = fPresentation.getSlideById('slide-1')
console.log(slide)
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getSlideByIndex`

Get a slide by index.

```typescript
getSlideByIndex(index: number): FSlide | null
```

**Parameters**

* `index` — Required. The zero-based slide index.

**Returns**

The slide, or `null` if the index is out of range.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const firstSlide = fPresentation.getSlideByIndex(0)
console.log(firstSlide)
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.getSlides`

Get all slides in the presentation.

```typescript
getSlides(): FSlide[]
```

**Returns**

The slides in slide order.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const slides = fPresentation.getSlides()
console.log(slides)
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.insertSlide`

Insert a new slide at the specified index.

```typescript
insertSlide(index: number, options?: Partial<ISlidePage>): FSlide
```

**Parameters**

* `index` — Required. The zero-based insert index.
* `options` — Optional. Default: `{}`. The slide creation options.

**Returns**

The created slide.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const slide = fPresentation.insertSlide(0, { name: 'Opening' })
console.log(slide)
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md) · [`Partial`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts) · [`ISlidePage`](https://docs.univer.ai/zh-CN/reference/types/slide-page.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.moveSlide`

Move a slide to a new index.

```typescript
moveSlide(slide: FSlide, toIndex: number): boolean
```

**Parameters**

* `slide` — Required. The slide to move.
* `toIndex` — Required. The target zero-based index.

**Returns**

Whether the slide was moved successfully.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const firstSlide = fPresentation.getSlideByIndex(0)
if (firstSlide) {
  fPresentation.moveSlide(firstSlide, 1)
}
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.save`

Save and return the presentation snapshot.

```typescript
save(): ISlideData
```

**Returns**

The presentation snapshot.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const snapshot = fPresentation.save()
console.log(snapshot)
```

**Types:** [`ISlideData`](https://docs.univer.ai/zh-CN/reference/types/slide-data.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.setActiveSlide`

Set the active slide.

```typescript
setActiveSlide(slide: FSlide): this
```

**Parameters**

* `slide` — Required. The slide facade or slide id to activate.

**Returns**

This presentation, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
const secondSlide = fPresentation.getSlideByIndex(1)
if (secondSlide) {
  fPresentation.setActiveSlide(secondSlide)
}
```

**Types:** [`FSlide`](https://docs.univer.ai/zh-CN/reference/facade/slide.md)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.setName`

Set the presentation name.

```typescript
setName(name: string): this
```

**Parameters**

* `name` — Required. The new presentation name.

**Returns**

This presentation, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
fPresentation.setName('Quarterly Review')
```

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.setPageSize`

Set the default page size of the presentation.

```typescript
setPageSize(pageSize: Partial<ISlidePageSize>): this
```

**Parameters**

* `pageSize` — Required. The new default page size.

**Returns**

This presentation, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
fPresentation.setPageSize({
  width: 1024,
  preset: univerAPI.Enum.SlidePageSizePresetEnum.WideScreen16By10,
})
```

**Types:** [`Partial`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts) · [`ISlidePageSize`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

### `FPresentation.setPresentationBackgroundGraphics`

Set managed presentation background graphics.
The call updates master pages through `SetPresentationBackgroundGraphicsCommand`.

```typescript
setPresentationBackgroundGraphics(graphics: ISlidePresentationBackgroundGraphic[], options?: ISetPresentationBackgroundGraphicsOptions): this
```

**Parameters**

* `graphics` — Required. The managed background graphics.
* `options` — Optional. Default: `{}`. Target master options.

**Returns**

This presentation, for chaining.

**Examples**

```ts
const fPresentation = univerAPI.getActivePresentation()
fPresentation.setPresentationBackgroundGraphics(
  [
    {
      source: 'image-source-id',
      imageSourceType: univerAPI.Enum.ImageSourceType.UUID,
      fit: univerAPI.Enum.SlidePresentationBackgroundGraphicFitEnum.Cover,
    },
  ],
  {
    target: univerAPI.Enum.SlidePresentationBackgroundGraphicsTargetEnum.ActiveMaster,
  },
)
```

```tsx
const fPresentation = univerAPI.getActivePresentation()
const svg = `
<svg xmlns="http://www.w3.org/2000/svg" width="960" height="540" viewBox="0 0 960 540">
  <rect width="960" height="540" fill="#e0f2fe"/>
  <path d="M0 540 L960 0" stroke="#22c55e" stroke-width="90" opacity="0.45"/>
  <path d="M-120 420 L840 -120" stroke="#3b82f6" stroke-width="52" opacity="0.55"/>
  <circle cx="760" cy="150" r="90" fill="#f97316" opacity="0.65"/>
  <text x="64" y="455" font-size="54" font-family="Arial" fill="#0f172a">Deck background</text>
</svg>
`
const url = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`
fPresentation.setPresentationBackgroundGraphics(
  [
    {
      source: url,
      imageSourceType: univerAPI.Enum.ImageSourceType.BASE64,
      fit: univerAPI.Enum.SlidePresentationBackgroundGraphicFitEnum.Cover,
    },
  ],
  {
    target: univerAPI.Enum.SlidePresentationBackgroundGraphicsTargetEnum.AllMasters,
  },
)
```

**Types:** [`ISlidePresentationBackgroundGraphic`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/slide.type.d.ts) · [`ISetPresentationBackgroundGraphicsOptions`](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)

**Package:** [`@univerjs-pro/slides`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/slides.md) · [Type definitions](https://unpkg.com/@univerjs-pro/slides@1.0.0-rc.0/lib/types/facade/f-presentation.d.ts)
