Interface AnnotationProvider

    • Constructor Detail

    • Method Detail

      • getAnnotations

        @NonNull() abstract List<Annotation> getAnnotations(@IntRange(from = 0) int pageIndex)

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

        Note: this call may block for a while and should not be invoked on the main thread.

        Parameters:
        pageIndex - 0-indexed page number.
        Returns:

        List of annotations on the page with the given page number.

      • getAnnotationsAsync

        @NonNull() abstract Observable<List<Annotation>> getAnnotationsAsync(@IntRange(from = 0) int pageIndex)

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

        Parameters:
        pageIndex - 0-indexed page number.
        Returns:

        Observable stream of annotations on page.

      • getAnnotation

        @Nullable() abstract Annotation getAnnotation(@IntRange(from = 0) int pageIndex, int objectNumber)

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

        Note: this call may block for a while and should not be invoked on the main thread.

        Parameters:
        pageIndex - Page index of the page where the annotation is.
        objectNumber - Object number of the annotation to retrieve.
        Returns:

        The requested annotation or null if not found.

      • getAnnotationAsync

        @NonNull() abstract Maybe<Annotation> getAnnotationAsync(@IntRange(from = 0) int pageIndex, int objectNumber)

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

        Parameters:
        pageIndex - Page index of the page where the annotation is.
        objectNumber - Object number of the annotation to retrieve.
        Returns:

        An instance of Maybe that either emits the requested annotation in `onSuccess()` or terminates with `onCompleted()` or `onError()`.

      • getAnnotationsAsync

        @NonNull() abstract Observable<List<Annotation>> getAnnotationsAsync(@NonNull() Collection<Integer> objectNumbers)

        Returns annotations with given object numbers, asynchronously.

        Parameters:
        objectNumbers - Collection of object numbers to search for.
        Returns:

        Observable emitting list of found annotations.

      • getAllAnnotationsOfType

        @NonNull() abstract List<Annotation> getAllAnnotationsOfType(@NonNull() EnumSet<AnnotationType> types, int startIndex, int pageCount)

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

        Note: this call may block for a while and should not be invoked on the main thread. You can use getAllAnnotationsOfTypeAsync instead.

        Parameters:
        types - Annotation types to return.
        startIndex - Index of the page to start the search.
        pageCount - Number of pages to be included, starting the count with the startIndex page.
        Returns:

        List of all annotations of passed types in a document.

      • getAllAnnotationsOfTypeAsync

        @NonNull() abstract Observable<Annotation> getAllAnnotationsOfTypeAsync(@NonNull() EnumSet<AnnotationType> types, int startIndex, int pageCount)

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

        WARNING: Parsing all annotations in a document can take some time. If you have to use it as a synchronous call, use getAllAnnotationsOfType.

        Parameters:
        types - Annotation types to return.
        startIndex - Index of the page to start the search.
        pageCount - Number of pages to be included, starting the count with the startIndex page.
        Returns:

        Observable emitting all annotations of passed types in a document.

      • addAnnotationToPage

         abstract void addAnnotationToPage(@NonNull() Annotation annotation)

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

        Parameters:
        annotation - Annotation to be added to the document.
      • addAnnotationToPageAsync

        @NonNull() abstract Completable addAnnotationToPageAsync(@NonNull() Annotation annotation)

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

        Parameters:
        annotation - Annotation to be added to the document.
        Returns:

        Completable which has to be subscribed to for operation to run.

      • addAnnotationToPage

         abstract void addAnnotationToPage(@NonNull() Annotation annotation, int zIndex)

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

        Parameters:
        annotation - Annotation to be added to the document.
        zIndex - Z-index at which the annotation will be inserted.
      • addAnnotationToPageAsync

        @NonNull() abstract Completable addAnnotationToPageAsync(@NonNull() Annotation annotation, int zIndex)

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

        Parameters:
        annotation - Annotation to be added to the document.
        zIndex - Z-index at which the annotation will be inserted.
        Returns:

        Completable which has to be subscribed to for operation to run.

      • removeAnnotationFromPage

         abstract void removeAnnotationFromPage(@NonNull() 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 PSPDFKit (requires extra license flag), any replies to the removed annotation will be automatically removed as well from the document.

        Parameters:
        annotation - Annotation to be removed from the document.
      • moveAnnotation

         abstract void moveAnnotation(int pageIndex, int fromZIndex, int toZIndex)

        Moves the annotation to the specified z-index.

        Parameters:
        pageIndex - Index of the page on which to reorder the annotations.
        fromZIndex - The original z-index of the annotation that needs to be moved (from the specified page)
        toZIndex - Target z-index for the annotation to be moved to.
      • moveAnnotationAsync

        @NonNull() abstract Completable moveAnnotationAsync(int pageIndex, int fromZIndex, int toZIndex)

        Moves the annotation to the specified z-index asynchronously.

        Parameters:
        pageIndex - Index of the page on which to reorder the annotations.
        fromZIndex - The original z-index of the annotation that needs to be moved (from the specified page)
        toZIndex - Target z-index for the annotation to be moved to.
        Returns:

        Completable object completing after the move has been done.

      • moveAnnotation

         abstract void moveAnnotation(@NonNull() Annotation annotation, int zIndex)

        Moves the annotation to the specified z-index.

        Parameters:
        annotation - Annotation to move.
        zIndex - Target z-index to move the annotation to.
      • moveAnnotationAsync

        @NonNull() abstract Completable moveAnnotationAsync(@NonNull() Annotation annotation, int zIndex)

        Moves the annotation to the specified z-index asynchronously.

        Parameters:
        annotation - Annotation to move.
        zIndex - Target z-index to move the annotation to.
        Returns:

        Completable object completing after the move has been done.

      • moveAnnotation

         abstract void moveAnnotation(@NonNull() Annotation annotation, @NonNull() AnnotationZIndexMove zIndexMove)

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

        Parameters:
        annotation - Annotation to move.
        zIndexMove - Z-index move action to be applied on the given annotation.
      • moveAnnotationAsync

        @NonNull() abstract Completable moveAnnotationAsync(@NonNull() Annotation annotation, @NonNull() AnnotationZIndexMove zIndexMove)

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

        Parameters:
        annotation - Annotation to move.
        zIndexMove - Z-index move action to be applied on the given annotation.
        Returns:

        Completable object completing after the move has been done.

      • getZIndex

         abstract int getZIndex(@NonNull() Annotation annotation)

        Gets the z-index of the provided annotation.

        Parameters:
        annotation - Annotation for which to retrieve the z-index.
        Returns:

        Z-index of the targeted annotation on the page that it's on.

      • getZIndexAsync

        @NonNull() abstract Single<Integer> getZIndexAsync(@NonNull() Annotation annotation)

        Gets the z-index of the provided annotation.

        Parameters:
        annotation - Annotation for which to retrieve the z-index.
        Returns:

        A Single object that will contain the z-index as the value.

      • removeAnnotationFromPageAsync

        @NonNull() abstract Completable removeAnnotationFromPageAsync(@NonNull() Annotation annotation)

        Removes annotation from this document asynchronously.

        Parameters:
        annotation - Annotation to be removed from the document.
        Returns:

        Completable which has to be subscribed to for operation to run.

      • createAnnotationFromInstantJson

        @NonNull() abstract Annotation createAnnotationFromInstantJson(@NonNull() String annotationJson)

        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 will be notified of the creation.

        Parameters:
        annotationJson - Instant JSON representation of the annotation to be created.
        Returns:

        Annotation created from the provided Instant JSON. If creation of the annotation from JSON failed, this method throws an exception.

      • createAnnotationFromInstantJsonAsync

        @NonNull() abstract Single<Annotation> createAnnotationFromInstantJsonAsync(@NonNull() String annotationJson)

        Creates an annotation from the Instant JSON annotation format asynchronously. 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 will be notified of the creation.

        Parameters:
        annotationJson - Instant JSON representation of the annotation to be created.
        Returns:

        Single emitting annotation imported from provided Instant JSON or an error if creation of the annotation from JSON failed.

      • hasUnsavedChanges

         abstract boolean hasUnsavedChanges()

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

        Returns:

        true if annotations were modified in this document and the document should be saved.

      • addAppearanceStreamGenerator

         abstract void addAppearanceStreamGenerator(@NonNull() AppearanceStreamGenerator appearanceStreamGenerator)

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

        Appearance stream generators in this list are queried for all annotations in the document until one of them returns true from shouldUseGeneratorForAnnotation. This generator is then used to generate custom appearance stream by calling getDataProviderForAnnotation. If no such generator is found in the list, annotation's generator (set via setAppearanceStreamGenerator is used. Appearance stream generation fallbacks to default rendering if annotation has no appearance stream generator set.

        Note: This does not automatically remove existing appearance streams. The appearance stream only gets generated when the annotation has been modified or when calling generateAppearanceStream explicitly.

        Parameters:
        appearanceStreamGenerator - Appearance stream generator.
      • addAppearanceStreamGenerator

         abstract void addAppearanceStreamGenerator(@NonNull() AppearanceStreamGenerator appearanceStreamGenerator, boolean addFirst)

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

        Appearance stream generators in this list are queried in order until one of them returns true from shouldUseGeneratorForAnnotation. This generator is then used to generate custom appearance stream for the annotation by calling getDataProviderForAnnotation. If no such generator is found in the list, annotation's generator (set via setAppearanceStreamGenerator is used. Appearance stream generation fallbacks to default rendering if annotation has no appearance stream generator set.

        Note: This does not automatically remove existing appearance streams. The appearance stream only gets generated when the annotation has been modified or when calling generateAppearanceStream explicitly.

        Parameters:
        appearanceStreamGenerator - Appearance stream generator.
        addFirst - Adds appearance stream generator to the beginning of the list.
      • getAnnotationReplies

        @NonNull() abstract List<Annotation> getAnnotationReplies(@NonNull() Annotation annotation)

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

        Parameters:
        annotation - Annotation whose replies we're fetching.
        Returns:

        List of top-level replies to the given annotation, or an empty list if none are available.

      • getAnnotationRepliesAsync

        @NonNull() abstract Single<List<Annotation>> getAnnotationRepliesAsync(@NonNull() Annotation annotation)

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

        Parameters:
        annotation - Annotation whose replies we're fetching.
        Returns:

        Single that emits a list of first-level replies to the given annotation.

      • getFlattenedAnnotationReplies

        @NonNull() abstract List<Annotation> getFlattenedAnnotationReplies(@NonNull() Annotation annotation)

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

        Parameters:
        annotation - Annotation whose replies we're fetching.
        Returns:

        List all replies (flattened) to the given annotation, or an empty list if none are available.

      • getFlattenedAnnotationRepliesAsync

        @NonNull() abstract Single<List<Annotation>> getFlattenedAnnotationRepliesAsync(@NonNull() Annotation annotation)

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

        Parameters:
        annotation - Annotation whose replies we're fetching.
        Returns:

        Single that emits a list of all replies (flattened) to the given annotation.

      • appendAnnotationState

         abstract void appendAnnotationState(@NonNull() Annotation annotation, @NonNull() AnnotationStateChange annotationStateChange)

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

        Parameters:
        annotation - Annotation for which to set the state.
        annotationStateChange - New annotation state to be set.
      • appendAnnotationStateAsync

        @NonNull() abstract Completable appendAnnotationStateAsync(@NonNull() Annotation annotation, @NonNull() AnnotationStateChange annotationStateChange)

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

        Parameters:
        annotation - Annotation for which to set the state.
        annotationStateChange - New annotation state to be set.
        Returns:

        A Completable that completes once the annotation state has been appended.

      • getReviewSummary

        @Nullable() abstract AnnotationReviewSummary getReviewSummary(@NonNull() Annotation annotation, @Nullable() String currentUser)

        Gets a summary information about the given annotation's review state.

        Parameters:
        annotation - Annotation for which to get the review summary.
        currentUser - The name of the current user, null to avoid including the current user into the review summary.
        Returns:

        Annotation review summary, or null if it could not be retrieved.

      • getReviewSummaryAsync

        @NonNull() abstract Maybe<AnnotationReviewSummary> getReviewSummaryAsync(@NonNull() Annotation annotation, @Nullable() String currentUser)

        Gets a summary information about the given annotation's review state asynchronously.

        Parameters:
        annotation - Annotation for which to get the review summary.
        currentUser - The name of the current user, null to avoid including the current user into the review summary.
        Returns:

        Maybe returning the given annotation review summary, or none if it could not be retrieved.

      • getReviewHistory

        @NonNull() abstract List<AnnotationStateChange> getReviewHistory(@NonNull() Annotation annotation)

        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.

        Parameters:
        annotation - Annotation for which to retrieve the review history.
        Returns:

        List of annotation state changes ordered chronologically.

      • getReviewHistoryAsync

        @NonNull() abstract Single<List<AnnotationStateChange>> getReviewHistoryAsync(@NonNull() Annotation annotation)

        Gets the review history of an annotation asynchronously. 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.

        Parameters:
        annotation - Annotation for which to retrieve the review history.
        Returns:

        Single emitting a list of annotation state changes ordered chronologically.