public interface

InstantPdfDocument

implements PdfDocument
com.pspdfkit.instant.document.InstantPdfDocument

Class Overview

PDF document managed by Instant. To create an instance use openDocument(String) or openDocumentAsync(String).

Summary

Constants
long SYNC_LOCAL_CHANGES_DISABLED Use in setDelayForSyncingLocalChanges(long) to deactivate automatic pushing of local changes.
[Expand]
Inherited Constants
From interface com.pspdfkit.document.PdfDocument
Public Methods
abstract void addInstantDocumentListener(InstantDocumentListener listener)

Adds listener for instant document events.

abstract InstantAnnotationProvider getAnnotationProvider()
Returns AnnotationProvider object which handles annotations contained in this document.
abstract long getDelayForSyncingLocalChanges()
Returns delay of automatic syncing of local changes that were made to the document.
abstract InstantDocumentState getDocumentState()
Returns the current state of this Instant document.
abstract InstantClient getInstantClient()
Returns instant client managing this document.
abstract InstantDocumentDescriptor getInstantDocumentDescriptor()
Returns instant document handle for this document.
abstract boolean isListeningToServerChanges()
Checks whether this document listens to server changes.
abstract void notifyConnectivityChanged(boolean isConnected)
Notify Instant that connection has changed.
abstract void reauthenticateWithJwt(String jwt)

Updates the token used to authenticate access to the document with a new JWT.

abstract Completable reauthenticateWithJwtAsync(String jwt)
Updates the token used to authenticate access to the document with a new JWT, asynchronously.
abstract void removeInstantDocumentListener(InstantDocumentListener listener)
Removes listener, previously registered via addInstantDocumentListener(InstantDocumentListener).
abstract void removeLocalStorage()
Removes local storage for this document.
abstract void setDelayForSyncingLocalChanges(long syncDelay)

Delay in milliseconds before kicking off automatic sync after local changes are made to the document.

abstract void setListenToServerChanges(boolean listenToServerChanges)

Controls whether to listen to server changes for this document.

abstract void syncAnnotations()
Starts annotation sync and waits for its completion.
abstract Flowable<InstantProgress> syncAnnotationsAsync()
Syncs annotations with instant server asynchronously.
[Expand]
Inherited Methods
From interface com.pspdfkit.document.PdfDocument

Constants

public static final long SYNC_LOCAL_CHANGES_DISABLED

Use in setDelayForSyncingLocalChanges(long) to deactivate automatic pushing of local changes.

Constant Value: 9223372036854775807 (0x7fffffffffffffff)

Public Methods

public abstract void addInstantDocumentListener (InstantDocumentListener listener)

Adds listener for instant document events. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.

Note: All listener methods are dispatched on the main UI thread.

Parameters
listener InstantDocumentListener that should be notified. Must be non-null.

public abstract InstantAnnotationProvider getAnnotationProvider ()

Returns AnnotationProvider object which handles annotations contained in this document.

Returns
  • The annotation provider.

public abstract long getDelayForSyncingLocalChanges ()

Returns delay of automatic syncing of local changes that were made to the document.

Returns
  • Delay in ms for automatic pushing of local changes to Instant server or SYNC_LOCAL_CHANGES_DISABLED when automatic pushing of local changes is disabled.

public abstract InstantDocumentState getDocumentState ()

Returns the current state of this Instant document.

Returns
  • Instant document state.

public abstract InstantClient getInstantClient ()

Returns instant client managing this document.

public abstract InstantDocumentDescriptor getInstantDocumentDescriptor ()

Returns instant document handle for this document.

public abstract boolean isListeningToServerChanges ()

Checks whether this document listens to server changes.

When listening to server changes is enabled, changes to document from other clients will be downloaded and applied automatically.

Returns
  • true when document is listening to server changes, false otherwise.

public abstract void notifyConnectivityChanged (boolean isConnected)

Notify Instant that connection has changed. Calling this method is optional. Annotation sync behaves by default as if being connected all the time. Failed requests are retried with increasing backoff when sync fails.

public abstract void reauthenticateWithJwt (String jwt)

Updates the token used to authenticate access to the document with a new JWT. This allows annotations to be synced again after the initial token used to download the document has expired.


Note: This method blocks current thread, waiting for authentication process to complete.

Parameters
jwt JWT used to authenticate access to the document.

public abstract Completable reauthenticateWithJwtAsync (String jwt)

Updates the token used to authenticate access to the document with a new JWT, asynchronously. This allows annotations to be synced again after the initial JWT used to download the document has expired.

Scheduler:
reauthenticateWithJwtAsync does not operate by default on a particular Scheduler.

Parameters
jwt JWT used to authenticate access to the document.
Returns
  • Completable emitting failure when authentication fails and completion when authentication succeeds.

public abstract void removeInstantDocumentListener (InstantDocumentListener listener)

Removes listener, previously registered via addInstantDocumentListener(InstantDocumentListener). Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.

Parameters
listener InstantDocumentListener that should be removed. Must be non-null.

public abstract void removeLocalStorage ()

Removes local storage for this document. Document will be invalid after returning from this method. Use this to clean-up locally cached data for documents that won't be used anymore or that has been corrupted due to internal error.

public abstract void setDelayForSyncingLocalChanges (long syncDelay)

Delay in milliseconds before kicking off automatic sync after local changes are made to the document.

Setting this to a higher value will reduce the load on the network and reduce energy use but means other users will not see annotation updates as soon, which also increases the chance of sync conflicts. Setting this to a positive value less than 1000 ms may strain the network and battery and is not recommended.

Important: When using this constant, remember to also disable listening for server changes - Instant’s sync operations are always two-way, so any incoming changes from the server would cause your local changes to be sent to the server.

Parameters
syncDelay Delay in ms for automatic pushing of local changes to instant server. Defaults to 1000 ms. Setting this to SYNC_LOCAL_CHANGES_DISABLED deactivates automatic pushing of local changes. It's callers responsibility to call syncAnnotationsAsync() to push latest changes in that case.

public abstract void setListenToServerChanges (boolean listenToServerChanges)

Controls whether to listen to server changes for this document.

When listening to server changes is enabled, changes to document from other clients will be downloaded and applied automatically.

Parameters
listenToServerChanges true to get immediate server updates. false to disable listening for server changes. It's callers responsibility to call syncAnnotationsAsync() to retrieve latest changes in that case.

public abstract void syncAnnotations ()

Starts annotation sync and waits for its completion.

public abstract Flowable<InstantProgress> syncAnnotationsAsync ()

Syncs annotations with instant server asynchronously.

Scheduler:
syncAnnotationsAsync does not operate by default on a particular Scheduler.

Returns
  • Flowable emitting annotations sync progress.