# FPdfAnnotation

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/pdf-annotation](https://docs.univer.ai/zh-CN/reference/facade/pdf-annotation)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/pdf-annotation.md](https://docs.univer.ai/zh-CN/reference/facade/pdf-annotation.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/pdf-annotation.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/pdf-annotation.mdx)

---

Facade for one durable editable PDF annotation.

## Access

Access through:

* [`FPdfPage.getAnnotations()`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page.md#getannotations)
* [`FPdfPage.insertAnnotation()`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page.md#insertannotation)

## Inheritance

Extends [`FPdfPageElement`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page-element.md). Its inherited members are available on this object.

## Example

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const annotation = page.insertAnnotation({
  annotationType: univerAPI.Enum.PdfAnnotationType.HIGHLIGHT,
  left: 36,
  top: 72,
  width: 180,
  height: 18,
})
console.log(annotation.getAnnotationType())
console.log(annotation.getMarkup())
console.log(annotation.getStyle())

annotation.setStyle({
  fill: { color: '#fff59d' },
  opacity: 0.6,
})
```

## Setup

Register [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) or a preset that includes it. In plugin mode, import `@univerjs-pro/pdfs/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/pdfs/getting-started/facade.md).

## `@univerjs-pro/pdfs`

### `FPdfAnnotation.getAnnotationType`

Return the annotation subtype.

```typescript
getAnnotationType(): PdfAnnotationType
```

**Returns**

The annotation subtype.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const annotation = page.getAnnotations()[0]
console.log(annotation?.getAnnotationType())
```

**Types:** [`PdfAnnotationType`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/enums.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-annotation.d.ts)

### `FPdfAnnotation.getInk`

Return detached ink geometry.

Coordinates are returned in PDF points.

```typescript
getInk(): Readonly<IPdfAnnotationInk> | null
```

**Returns**

The ink geometry, or `null` for another subtype.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const annotation = page.getAnnotations()[0]
console.log(annotation?.getInk())
```

**Types:** [`Readonly`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts) · [`IPdfAnnotationInk`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/types.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-annotation.d.ts)

### `FPdfAnnotation.getMarkup`

Return detached markup geometry.

Coordinates are returned in PDF points.

```typescript
getMarkup(): Readonly<IPdfAnnotationMarkup> | null
```

**Returns**

The markup geometry, or `null` for another subtype.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const annotation = page.getAnnotations()[0]
console.log(annotation?.getMarkup())
```

**Types:** [`Readonly`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts) · [`IPdfAnnotationMarkup`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/types.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-annotation.d.ts)

### `FPdfAnnotation.getStyle`

Return the supported appearance projected from subtype data.

```typescript
getStyle(): Readonly<IPdfAnnotationStyle>
```

**Returns**

The supported appearance snapshot.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const annotation = page.getAnnotations()[0]
console.log(annotation?.getStyle())
```

**Types:** [`IPdfAnnotationStyle`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/types.d.ts) · [`Readonly`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-annotation.d.ts)

### `FPdfAnnotation.setStyle`

Update model-supported annotation fill, stroke, and opacity fields.

```typescript
setStyle(style: IPdfAnnotationStyle): this
```

**Parameters**

* `style` — Required. The appearance patch.

**Returns**

This annotation Facade for chaining.

**Throws**

If opacity is outside the inclusive 0-through-1 range.

If the annotation is stale or the durable command is rejected.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const annotation = page.getAnnotations()[0]
if (annotation) {
  annotation.setStyle({
    fill: {
      color: '#fff59d',
    },
    stroke: {
      color: '#fbc02d',
      width: 1,
    },
    opacity: 0.6,
  })
}
```

**Types:** [`IPdfAnnotationStyle`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/types.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-annotation.d.ts)
