# Import and export

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

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

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

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

---

The APIs below need a conversion backend. Follow [file exchange integration](https://docs.univer.ai/server/import-export.md) to connect uploads, conversion, task queries, and downloads, then configure the browser plugins. Snapshot APIs also need that backend, but do not require a collaborative document. The collaboration Exchange example demonstrates Sheets; check that your target release supports the file types you need.

#### Package metadata

```json
{
  "preset": [],
  "plugins": [
    {
      "client": "@univerjs-pro/exchange-client",
      "locale": "@univerjs-pro/exchange-client/locale/en-US",
      "style": "@univerjs-pro/exchange-client/lib/index.css",
      "facade": "@univerjs-pro/exchange-client/facade"
    },
    {
      "client": "@univerjs-pro/pdfs-exchange-client",
      "locale": "@univerjs-pro/pdfs-exchange-client/locale/en-US",
      "facade": "@univerjs-pro/pdfs-exchange-client/facade"
    }
  ],
  "server": true
}
```

## Supported formats

The table describes the browser APIs on this page. Office file conversion requires a backend that supports the same document type and format.

| Import | Export |
| ------ | ------ |
| `.pdf` | `.pdf` |

These APIs import and export PDF files. They do not convert PDF content to DOCX, XLSX, or PPTX. Browser printing is a separate workflow.

## Choose a data path

| Path     | Persists a server unit | Requires collaboration | Conversion server |
| -------- | :--------------------: | :--------------------: | :---------------: |
| Unit ID  |           Yes          |           Yes          |      Required     |
| Snapshot |           No           |           No           |      Required     |

### Import to a persisted unit

The input can be a browser `File` or a URL. Load the returned unit through the configured collaboration client.

```ts
const unitId = await univerAPI.importPdfToUnitIdAsync(file)

if (unitId) {
  const pdf = await univerAPI.getCollaboration().loadPdfAsync(unitId)
  console.log(pdf?.getName())
}
```

### Import to a snapshot

Use snapshot import for a local PDF unit that should not be persisted as part of the conversion task:

```ts
const snapshot = await univerAPI.importPdfToSnapshotAsync(file)

if (snapshot) {
  univerAPI.createPdf(snapshot)
}
```

### Export and download

Export a persisted unit by ID:

```ts
const file = await univerAPI.exportPdfByUnitIdAsync(unitId)

if (file) {
  univerAPI.downloadFile(file, 'project-brief', 'pdf')
}
```

Export the current local snapshot without persisting it first:

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

if (pdf) {
  const file = await univerAPI.exportPdfBySnapshotAsync(pdf.save())

  if (file) {
    univerAPI.downloadFile(file, pdf.getName(), 'pdf')
  }
}
```

These APIs return a `File`. Browser printing is a separate workflow that opens the system print dialog; see [Print](https://docs.univer.ai/guides/pdfs/features/print.md).
