# 주석과 네이티브 텍스트

> 지원되는 PDF 주석을 삽입하고 가져온 네이티브 텍스트를 편집 가능한 텍스트 상자로 승격합니다.

- Human documentation: [https://docs.univer.ai/ko-KR/guides/pdfs/features/core/annotations-and-native-text](https://docs.univer.ai/ko-KR/guides/pdfs/features/core/annotations-and-native-text)

- Agent Markdown: [https://docs.univer.ai/ko-KR/guides/pdfs/features/core/annotations-and-native-text.md](https://docs.univer.ai/ko-KR/guides/pdfs/features/core/annotations-and-native-text.md)

- Requested language: `ko-KR`

- Content language: `ko-KR`

- Documentation version: `1.0.4`

- Source: [pdfs/features/core/annotations-and-native-text.ko-KR.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/pdfs/features/core/annotations-and-native-text.ko-KR.mdx)

---

편집 가능한 주석은 영속 오버레이입니다. 가져온 텍스트는 보이는 텍스트 범위를 퍼사드로 승격할 때까지 네이티브 상태로 유지됩니다.

## 주석 삽입

```ts
const highlight = page.insertAnnotation({
  annotationType: univerAPI.Enum.PdfAnnotationType.HIGHLIGHT,
  left: 36,
  top: 72,
  width: 180,
  height: 18,
  markup: {
    color: '#fde047',
    opacity: 0.6,
  },
})
```

퍼사드 삽입은 하이라이트, 밑줄, 취소선, 물결 밑줄 및 잉크 주석을 지원합니다. 잉크에는 비어 있지 않은 경로가 필요하며 다른 코어 주석 하위 타입은 이 API에서 허용되지 않습니다.

## 주석 데이터 및 스타일 읽기

```ts
const markup = highlight.getMarkup()
const style = highlight.getStyle()

highlight.setStyle({
  stroke: { color: '#ca8a04', width: 1 },
  opacity: 0.75,
})
```

`getMarkup()`과 `getInk()`는 PDF 포인트의 분리된 기하 정보를 반환합니다. `setStyle()`은 지원되는 채우기, 선 및 불투명도를 업데이트하며 불투명도는 `0`부터 `1` 사이여야 합니다.

## 가져온 네이티브 텍스트 바꾸기

```ts
const matchingSpan = page
  .getTextSpans()
  .find((span) => span.getText().includes('Draft'))

if (matchingSpan) {
  const textBox = matchingSpan.replaceText('Final')
  textBox.setTextStyle({ bold: true })
}
```

`getTextSpans()`는 현재 표시되고 숨겨지지 않은 네이티브 텍스트의 스냅샷을 반환합니다. `replaceText()`는 원본 작업을 원자적으로 숨기고 캡처된 위치에 편집 가능한 `FPdfTextBox`를 삽입합니다.

`FPdfTextSpan`은 스냅샷 핸들입니다. 바꾼 뒤에는 유효하지 않으므로 다음 네이티브 텍스트 작업 전에 `getTextSpans()`를 다시 열거하세요.
