FPdfTextSpan
Snapshot Facade for one visible native PDF text display operation.
Access
Access through:
Example
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.
getBounds(): IPdfFacadeBoundsReturns
The captured bounds in points.
Examples
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.
getId(): stringReturns
The native-span ID.
Examples
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.
getText(): stringReturns
The captured native text.
Examples
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.
getTextRuns(): readonly IPdfTextRun[]Returns
The captured text-run snapshots.
Examples
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.
replaceText(text: string): FPdfTextBoxParameters
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
const pdf = univerAPI.getActivePdf()const span = pdf?.getPageByIndex(0)?.getTextSpans()[0]const textBox = span ? span.replaceText('Editable text') : nullTypes: FPdfTextBox
Package: @univerjs-pro/pdfs · Type definitions
How is this guide?