# FPdfTextSpan

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

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

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

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

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

---

Snapshot Facade for one visible native PDF text display operation.

## Access

Access through:

* [`FPdfPage.getTextSpans()`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page.md#gettextspans)

## Example

```ts
const pdf = univerAPI.getActivePdf()
console.log(pdf?.getPageByIndex(0)?.getTextSpans()[0]?.getText())
```

## 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`

### `FPdfTextSpan.getBounds`

Return the captured axis-aligned bounds in PDF points.

```typescript
getBounds(): IPdfFacadeBounds
```

**Returns**

The captured bounds in points.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
console.log(pdf?.getPageByIndex(0)?.getTextSpans()[0]?.getBounds())
```

**Types:** [`IPdfFacadeBounds`](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-text-span.d.ts)

### `FPdfTextSpan.getId`

Return an opaque deterministic native-span ID.

```typescript
getId(): string
```

**Returns**

The native-span ID.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
console.log(pdf?.getPageByIndex(0)?.getTextSpans()[0]?.getId())
```

**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-text-span.d.ts)

### `FPdfTextSpan.getText`

Return the text snapshot captured during enumeration.

```typescript
getText(): string
```

**Returns**

The captured native text.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
console.log(pdf?.getPageByIndex(0)?.getTextSpans()[0]?.getText())
```

**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-text-span.d.ts)

### `FPdfTextSpan.getTextRuns`

Return detached text-run snapshots captured during enumeration.

```typescript
getTextRuns(): readonly IPdfTextRun[]
```

**Returns**

The captured text-run snapshots.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
console.log(pdf?.getPageByIndex(0)?.getTextSpans()[0]?.getTextRuns())
```

**Types:** [`IPdfTextRun`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/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-text-span.d.ts)

### `FPdfTextSpan.replaceText`

Atomically suppress this native span and replace it with an editable text box.

```typescript
replaceText(text: string): FPdfTextBox
```

**Parameters**

* `text` — Required. The replacement text, including an empty string.

**Returns**

The promoted editable text-box Facade.

**Throws**

If the native span is stale, already replaced, or the durable command is rejected.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const span = pdf?.getPageByIndex(0)?.getTextSpans()[0]
const textBox = span ? span.replaceText('Editable text') : null
```

**Types:** [`FPdfTextBox`](https://docs.univer.ai/zh-CN/reference/facade/pdf-text-box.md)

**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-text-span.d.ts)
