API 参考

FPdfTextSpan

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。

Snapshot Facade for one visible native PDF text display operation.

Access

Access through:

Example

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

Setup

Register @univerjs-pro/pdfs 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.

@univerjs-pro/pdfs

FPdfTextSpan.getBounds

Return the captured axis-aligned bounds in PDF points.

TypeScript
getBounds(): IPdfFacadeBounds

Returns

The captured bounds in points.

Examples

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

Types: IPdfFacadeBounds

Package: @univerjs-pro/pdfs · Type definitions

FPdfTextSpan.getId

Return an opaque deterministic native-span ID.

TypeScript
getId(): string

Returns

The native-span ID.

Examples

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

Package: @univerjs-pro/pdfs · Type definitions

FPdfTextSpan.getText

Return the text snapshot captured during enumeration.

TypeScript
getText(): string

Returns

The captured native text.

Examples

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

Package: @univerjs-pro/pdfs · Type definitions

FPdfTextSpan.getTextRuns

Return detached text-run snapshots captured during enumeration.

TypeScript
getTextRuns(): readonly IPdfTextRun[]

Returns

The captured text-run snapshots.

Examples

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

Types: IPdfTextRun

Package: @univerjs-pro/pdfs · Type definitions

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

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

Types: FPdfTextBox

Package: @univerjs-pro/pdfs · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.