> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/common/file-storage/pdf.md).

# PDF 뷰어

### PDF 뷰어 열기

**SDK 함수:** `openPDFViewer`

`openPDFViewer`는 Base64로 인코딩된 PDF 데이터를 네이티브 PDF 뷰어로 여는 함수예요. 사용자가 PDF 뷰어를 닫으면 `'CLOSE'`를 반환해요.

**시그니처**

```typescript
function openPDFViewer(params: OpenPDFViewerParams): Promise<OpenPDFViewerResult>;
```

**파라미터**

* params필수

  PDF 데이터와 파일 이름을 담은 객체예요. 자세한 타입은 아래 `OpenPDFViewerParams`를 참고하세요.

**반환값**

* Promise\<OpenPDFViewerResult>

  PDF 뷰어가 닫히면 `'CLOSE'`를 반환해요.

**에러**

| 에러 코드                     | 발생 조건                      |
| ------------------------- | -------------------------- |
| `INVALID_REQUEST`         | 요청 파라미터가 올바르지 않을 때         |
| `INVALID_DATA`            | PDF 데이터가 유효하지 않을 때         |
| `PDF_VIEWER_ERROR`        | PDF 뷰어를 여는 과정에서 오류가 발생했을 때 |
| `UNSUPPORTED_APP_VERSION` | 토스앱 버전이 5.261.0보다 낮을 때     |

**예제**

{% tabs %}
{% tab title="React" %}

```tsx
import { openPDFViewer } from '@apps-in-toss/web-framework';

async function showPdf() {
  try {
    const result = await openPDFViewer({
      data: 'JVBERi0xLjQK...',
      filename: 'document.pdf',
    });

    if (result === 'CLOSE') {
      console.log('PDF 뷰어가 닫혔어요.');
    }
  } catch (error) {
    console.error('PDF 뷰어 오류:', error);
  }
}
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { openPDFViewer } from '@apps-in-toss/framework';

async function showPdf() {
  try {
    const result = await openPDFViewer({
      data: 'JVBERi0xLjQK...',
      filename: 'document.pdf',
    });

    if (result === 'CLOSE') {
      console.log('PDF 뷰어가 닫혔어요.');
    }
  } catch (error) {
    console.error('PDF 뷰어 오류:', error);
  }
}
```

{% endtab %}
{% endtabs %}

### 타입 · 객체

**PDF 뷰어 파라미터 (`OpenPDFViewerParams`)**

`openPDFViewer` 함수에 전달하는 파라미터 타입이에요.

**시그니처**

```typescript
interface OpenPDFViewerParams {
  data: string;
  filename?: string;
}
```

**프로퍼티**

* datastring필수

  Base64 형식으로 인코딩된 PDF 데이터 문자열이에요.
* filenamestring

  PDF 파일 이름이에요.

**PDF 뷰어 결과 (`OpenPDFViewerResult`)**

PDF 뷰어가 닫혔을 때 반환되는 결과 타입이에요.

**시그니처**

```typescript
type OpenPDFViewerResult = 'CLOSE';
```

**값 설명**

| 값         | 설명                    |
| --------- | --------------------- |
| `'CLOSE'` | 사용자가 PDF 뷰어를 닫은 경우예요. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/common/file-storage/pdf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
