Annotations and Native Text

Insert supported PDF annotations and promote imported native text into editable text boxes.

Editable annotations are durable overlays. Imported text remains native until a visible text span is promoted through the Facade.

Insert annotations

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

Facade insertion supports highlight, underline, strikeout, squiggly, and ink annotations. Ink annotations require non-empty paths, and this insertion API rejects the other core annotation subtypes.

Read annotation data and style

TypeScript
const markup = highlight.getMarkup()const style = highlight.getStyle()highlight.setStyle({  stroke: { color: '#ca8a04', width: 1 },  opacity: 0.75,})

getMarkup() and getInk() return detached geometry measured in PDF points. setStyle() updates the supported fill, stroke, and opacity fields. Opacity must be between 0 and 1.

Replace imported native text

TypeScript
const matchingSpan = page  .getTextSpans()  .find((span) => span.getText().includes('Draft'))if (matchingSpan) {  const textBox = matchingSpan.replaceText('Final')  textBox.setTextStyle({ bold: true })}

getTextSpans() returns snapshots of native text that is currently visible and not suppressed. replaceText() suppresses the source operation and inserts an editable FPdfTextBox at the captured position as a single atomic step.

An FPdfTextSpan is a snapshot handle that becomes stale after replacement. Call getTextSpans() again before the next native-text operation.

How is this guide?

© 2026 DreamNum Co., Ltd.