FPdfAnnotation
Facade for one durable editable PDF annotation.
Access
Access through:
Inheritance
Extends FPdfPageElement. Its inherited members are available on this object.
Example
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.
getAnnotationType(): PdfAnnotationTypeReturns
The annotation subtype.
Examples
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.
getInk(): Readonly<IPdfAnnotationInk> | nullReturns
The ink geometry, or null for another subtype.
Examples
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.
getMarkup(): Readonly<IPdfAnnotationMarkup> | nullReturns
The markup geometry, or null for another subtype.
Examples
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.
getStyle(): Readonly<IPdfAnnotationStyle>Returns
The supported appearance snapshot.
Examples
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.
setStyle(style: IPdfAnnotationStyle): thisParameters
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
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
How is this guide?