Référence de l’API

FPdfAnnotation

Cette page API est actuellement disponible en anglais. Les signatures et identifiants restent identiques dans toutes les langues.

Facade for one durable editable PDF annotation.

Access

Access through:

Inheritance

Extends FPdfPageElement. Its inherited members are available on this object.

Example

TypeScript
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 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

FPdfAnnotation.getAnnotationType

Return the annotation subtype.

TypeScript
getAnnotationType(): PdfAnnotationType

Returns

The annotation subtype.

Examples

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

Types: PdfAnnotationType

Package: @univerjs-pro/pdfs · Type definitions

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

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

Types: Readonly · IPdfAnnotationInk

Package: @univerjs-pro/pdfs · Type definitions

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

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

Types: Readonly · IPdfAnnotationMarkup

Package: @univerjs-pro/pdfs · Type definitions

FPdfAnnotation.getStyle

Return the supported appearance projected from subtype data.

TypeScript
getStyle(): Readonly<IPdfAnnotationStyle>

Returns

The supported appearance snapshot.

Examples

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

Types: IPdfAnnotationStyle · Readonly

Package: @univerjs-pro/pdfs · Type definitions

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

TypeScript
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

Package: @univerjs-pro/pdfs · Type definitions

Que pensez-vous de ce guide ?

© 2026 DreamNum Co., Ltd.