AnnotationProvider

Handles all annotation related operations on the owning document. Retrieve it with com.pspdfkit.document.PdfDocument.getAnnotationProvider.

For RxJava based code, see the interoperability helpers in AnnotationProviderRxJava, which bridge the suspend APIs exposed here to Rx types for legacy Java integrations.

Inheritors

Types

Link copied to clipboard
object Companion

Companion object containing constants and utilities for AnnotationProvider.

Link copied to clipboard

Listener for annotation update events inside AnnotationProvider.

Functions

Link copied to clipboard
abstract suspend fun addAnnotationToPage(annotation: Annotation)

Adds annotation to the owner PDF document asynchronously using Kotlin coroutines. The annotation will be attached to the page set in its constructor.

abstract suspend fun addAnnotationToPage(annotation: Annotation, zIndex: Int)

Adds annotation to the owner PDF document at the specified z-index. The annotation will be attached to the page set in its constructor.

Link copied to clipboard

Adds annotation to the owner PDF document, blocking until the operation completes.

Link copied to clipboard

Adds the provided annotation to the page via AnnotationProvider.addAnnotationToPage and exposes the result as a Completable.

Link copied to clipboard
abstract fun addAppearanceStreamGenerator(appearanceStreamGenerator: AppearanceStreamGenerator)
abstract fun addAppearanceStreamGenerator(appearanceStreamGenerator: AppearanceStreamGenerator, addFirst: Boolean)

Adds appearance stream generator to the list of global appearance stream generators.

Link copied to clipboard
abstract suspend fun appendAnnotationState(annotation: Annotation, annotationStateChange: AnnotationStateChange)

Appends a new annotation state for the given annotation (adds it to the review history).

Link copied to clipboard
abstract suspend fun createAnnotationFromInstantJson(annotationJson: String): Annotation

Creates an annotation from the Instant JSON annotation format. The JSON must contain the type, the page number and any other required properties for that type. The created annotation will be automatically added to the document, and any registered OnAnnotationUpdatedListener will be notified of the creation.

Link copied to clipboard
abstract suspend fun getAllAnnotationsOfType(types: Set<ERROR CLASS: Symbol not found for AnnotationType>): List<Annotation>

Returns all annotations of passed types in this document.

abstract suspend fun getAllAnnotationsOfType(types: Set<ERROR CLASS: Symbol not found for AnnotationType>, startIndex: Int, pageCount: Int): List<Annotation>

Returns all annotations of passed types in the specified page index range.

Link copied to clipboard
fun AnnotationProvider.getAllAnnotationsOfTypeBlocking(types: EnumSet<ERROR CLASS: Symbol not found for AnnotationType>): List<Annotation>

Returns all annotations of passed types in this document, blocking until the operation completes.

fun AnnotationProvider.getAllAnnotationsOfTypeBlocking(types: EnumSet<ERROR CLASS: Symbol not found for AnnotationType>, @IntRange(from = 0) startPageIndex: Int, @IntRange(from = 1) pageCount: Int): List<Annotation>

Returns all annotations of passed types in the specified page range, blocking until the operation completes.

Link copied to clipboard
fun AnnotationProvider.getAllAnnotationsOfTypeObservable(types: EnumSet<ERROR CLASS: Symbol not found for AnnotationType>): Observable<Annotation>

Returns all annotations of the given types for the entire document as an Observable, using AnnotationProvider.getAllAnnotationsOfType.

fun AnnotationProvider.getAllAnnotationsOfTypeObservable(types: EnumSet<ERROR CLASS: Symbol not found for AnnotationType>, startIndex: Int, pageCount: Int): Observable<Annotation>

Returns annotations of the given types for the provided page range as an Observable, using AnnotationProvider.getAllAnnotationsOfType.

Link copied to clipboard
abstract suspend fun getAnnotation(@IntRange(from = 0) pageIndex: Int, objectNumber: Int): Annotation?

Returns annotation with certain object ID on the page if it exists.

abstract suspend fun getAnnotation(@IntRange(from = 0) pageIndex: Int, uuid: String): Annotation?

Returns annotation with certain UUID on the page if it exists, asynchronously.

Link copied to clipboard
fun AnnotationProvider.getAnnotationBlocking(@IntRange(from = 0) pageIndex: Int, objectNumber: Int): Annotation?

Returns annotation with certain object ID on the page if it exists, blocking until the operation completes.

Returns annotation with certain UUID on the page if it exists, blocking until the operation completes.

Link copied to clipboard
abstract suspend fun getAnnotationReplies(annotation: Annotation): List<Annotation>

Gets all first-level replies to a particular annotation. First-level replies are annotations that return the given annotation via Annotation.getInReplyTo. The sort order is determined by the creation date.

Link copied to clipboard
abstract suspend fun getAnnotations(@IntRange(from = 0) pageIndex: Int): List<Annotation>

Returns a list of annotations on the page. For annotations not currently recognised and handled by Nutrient this returns UnknownAnnotation.

abstract suspend fun getAnnotations(objectNumbers: Collection<Int>): List<Annotation>

Returns annotations with given object numbers.

Link copied to clipboard

Returns a list of annotations on the page, blocking until the operation completes.

Link copied to clipboard
abstract suspend fun getAnnotationsJson(@IntRange(from = 0) pageIndex: Int): String

Returns a JSON array in string format of annotations on the page.

Link copied to clipboard

Returns all annotations on the given page as an Observable by bridging AnnotationProvider.getAnnotations.

Link copied to clipboard
abstract suspend fun getFlattenedAnnotationReplies(annotation: Annotation): List<Annotation>

Gets all flattened replies (all replies included but no nesting) to a particular annotation. The sort order is determined by the creation date.

Link copied to clipboard
abstract suspend fun getReviewHistory(annotation: Annotation): List<AnnotationStateChange>

Gets the review history of an annotation. The review history of an annotation is the list of states it has passed, for example, "Accepted", "Cancelled", and so on. This list is ordered chronologically, where the last element is the most current one according to the creation date of the annotation change.

Link copied to clipboard
abstract suspend fun getReviewSummary(annotation: Annotation, currentUser: String?): AnnotationReviewSummary?

Gets a summary information about the given annotation's review state. Suspends while the summary is retrieved off the main thread.

Link copied to clipboard
abstract suspend fun getZIndex(annotation: Annotation): Int

Gets the z-index of the provided annotation.

Link copied to clipboard
abstract fun hasUnsavedChanges(): Boolean

Returns whether there are unsaved changes to annotations in this document.

Link copied to clipboard
abstract suspend fun moveAnnotation(annotation: Annotation, zIndexMove: AnnotationZIndexMove)

Moves the annotation with the specified z-index move action.

abstract suspend fun moveAnnotation(annotation: Annotation, zIndex: Int)
abstract suspend fun moveAnnotation(pageIndex: Int, fromZIndex: Int, toZIndex: Int)

Moves the annotation to the specified z-index.

Link copied to clipboard
abstract suspend fun removeAnnotationFromPage(annotation: Annotation)

Removes annotation from the document. If the annotation is not attached to the document of this annotation provider, this will be a no-op. Note that when using the Replies component of Nutrient (requires extra license flag), any replies to the removed annotation will be automatically removed as well from the document.

Link copied to clipboard

Removes annotation from the document, blocking until the operation completes.

Link copied to clipboard
abstract fun removeAppearanceStreamGenerator(appearanceStreamGenerator: AppearanceStreamGenerator)

Remove appearance stream generator that was previously added in addAppearanceStreamGenerator.