# 가져오기 및 내보내기

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

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

- Requested language: `ko-KR`

- Content language: `ko-KR`

- Documentation version: `1.0.4`

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

---

아래 브라우저 API를 사용하기 전에 [가져오기·내보내기 통합](https://docs.univer.ai/ko-KR/server/import-export.md)을 완료하세요. 앱에서 업로드, 변환, 작업 조회 및 권한이 적용된 다운로드 계약을 구현해야 합니다. 스냅샷 API도 변환 백엔드가 필요합니다. [Exchange 예제](https://docs.univer.ai/ko-KR/server/collaboration/examples.md#exchange)는 Sheets를 다루므로 다른 제품과 형식의 지원 범위는 별도로 확인하세요.

#### Package metadata

```json
{
  "preset": [],
  "plugins": [
    {
      "client": "@univerjs-pro/exchange-client",
      "locale": "@univerjs-pro/exchange-client/locale/ko-KR",
      "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/ko-KR",
      "facade": "@univerjs-pro/pdfs-exchange-client/facade"
    }
  ],
  "license": true,
  "server": true
}
```

## 지원 형식

아래 표는 이 페이지의 브라우저 API가 지원하는 형식입니다. Office 파일 변환에는 해당 문서 유형과 형식을 지원하는 백엔드가 필요합니다.

| 가져오기   | 내보내기   |
| ------ | ------ |
| `.pdf` | `.pdf` |

## 데이터 경로 선택

| 경로    | 서버 유닛 저장 | 협업 필요 | 변환 서버 |
| ----- | :------: | :---: | :---: |
| 유닛 ID |     예    |   예   |   필요  |
| 스냅샷   |    아니요   |  아니요  |   필요  |

### 저장된 유닛으로 가져오기

입력은 브라우저 `File` 또는 URL일 수 있습니다. 설정한 협업 클라이언트를 통해 반환된 유닛을 불러오세요.

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

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

### 스냅샷으로 가져오기

변환 작업의 일부로 저장하면 안 되는 로컬 PDF 유닛에는 스냅샷 가져오기를 사용하세요.

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

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

### 내보내기 및 다운로드

저장된 유닛을 ID로 내보내세요.

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

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

현재 로컬 스냅샷을 먼저 저장하지 않고 내보내세요.

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

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

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

이 API는 `File`을 반환합니다. 브라우저 인쇄는 시스템 인쇄 대화 상자를 여는 별도의 워크플로입니다. [인쇄](https://docs.univer.ai/ko-KR/guides/pdfs/features/print.md)를 참고하세요.
