# Univer PDFs API

> Create, find, save, enter, and unload PDF units through the PDF Facade API.

- Human documentation: [https://docs.univer.ai/guides/pdfs/features/core/pdfs-api](https://docs.univer.ai/guides/pdfs/features/core/pdfs-api)

- Agent Markdown: [https://docs.univer.ai/guides/pdfs/features/core/pdfs-api.md](https://docs.univer.ai/guides/pdfs/features/core/pdfs-api.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [pdfs/features/core/pdfs-api.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/pdfs/features/core/pdfs-api.mdx)

---

The PDF Facade adds PDF units and page entry points to `FUniver`. Import its side-effect entry before creating the API object.

## Enable the PDF Facade

```ts
import { FUniver } from '@univerjs/core/facade'

import '@univerjs-pro/pdfs/facade'

const univerAPI = FUniver.newAPI(univer)
```

Register `UniverPdfsPlugin` in the Univer instance so the application can host PDF units.

## Create, find, and save PDF units

When `document` is omitted, `createPdf()` creates a unit with one blank A4 page. Pass a snapshot previously returned by `save()` to restore a unit.

```ts
const pdf = univerAPI.createPdf({
  id: 'project-brief',
  name: 'Project brief',
})

const activePdf = univerAPI.getActivePdf()
const samePdf = univerAPI.getPdf(pdf.getId())
const snapshot = pdf.save()
```

Use Facade methods or commands to update a running PDF. Treat the saved snapshot as detached persistence data.

## Enter a page

`FPdfPage` is the common entry point for the page's editable overlays and imported native text:

```ts
const firstPage = pdf.getPageByIndex(0) ?? pdf.insertPage()
const elements = firstPage.getElements()
const nativeText = firstPage.getTextSpans()
```

Continue with [Pages and Elements](https://docs.univer.ai/guides/pdfs/features/core/pages-and-elements.md), [Text and Lists](https://docs.univer.ai/guides/pdfs/features/core/text-and-lists.md), [Tables](https://docs.univer.ai/guides/pdfs/features/core/tables.md), [Images and Dividers](https://docs.univer.ai/guides/pdfs/features/core/images-and-dividers.md), or [Annotations and Native Text](https://docs.univer.ai/guides/pdfs/features/core/annotations-and-native-text.md) for focused operations.

## Unload a PDF unit

Unload one PDF unit by ID when it is no longer needed. Dispose the root `univer` instance only when the whole application is being destroyed.

```ts
const pdf = univerAPI.getActivePdf()

if (pdf) {
  univerAPI.disposeUnit(pdf.getId())
}
```

For exact signatures and return types, see the [PDF Facade reference](https://docs.univer.ai/reference/facade/pdf.md).
