Interface InstantPdfDocument
-
- All Implemented Interfaces:
-
com.pspdfkit.document.PdfDocument
public interface InstantPdfDocument implements PdfDocument
PDF document managed by Instant. To create an instance use openDocument or openDocumentAsync.
-
-
Method Summary
Modifier and Type Method Description abstract InstantAnnotationProvider
getAnnotationProvider()
Returns AnnotationProvider object which handles annotations contained in this document. abstract InstantClient
getInstantClient()
Returns instant client managing this document. abstract InstantDocumentDescriptor
getInstantDocumentDescriptor()
Returns instant document handle for this document. abstract void
reauthenticateWithJwt(@NonNull() String jwt)
Updates the token used to authenticate access to the document with a new JWT. abstract Completable
reauthenticateWithJwtAsync(@NonNull() String jwt)
Updates the token used to authenticate access to the document with a new JWT, asynchronously. abstract void
syncAnnotations()
Starts annotation sync and waits for its completion. abstract Flowable<InstantProgress>
syncAnnotationsAsync()
Syncs annotations with Instant Server (PSPDFKit Document Engine) asynchronously. abstract void
addInstantDocumentListener(@NonNull() InstantDocumentListener listener)
Adds listener for instant document events. abstract void
removeInstantDocumentListener(@NonNull() InstantDocumentListener listener)
Removes listener, previously registered via addInstantDocumentListener. abstract void
notifyConnectivityChanged(boolean isConnected)
Notify Instant that connection has changed. abstract void
removeLocalStorage()
Removes local storage for this document. abstract void
setListenToServerChanges(boolean listenToServerChanges)
Controls whether to listen to server changes for this document. abstract boolean
isListeningToServerChanges()
Checks whether this document listens to server changes. abstract long
getDelayForSyncingLocalChanges()
Returns delay of automatic syncing of local changes that were made to the document. abstract void
setDelayForSyncingLocalChanges(long syncDelay)
Delay in milliseconds before kicking off automatic sync after local changes are made to the document. abstract InstantDocumentState
getDocumentState()
Returns the current state of this Instant document. -
-
Method Detail
-
getAnnotationProvider
@NonNull() abstract InstantAnnotationProvider getAnnotationProvider()
Returns AnnotationProvider object which handles annotations contained in this document.
- Returns:
The annotation provider.
-
getInstantClient
@NonNull() abstract InstantClient getInstantClient()
Returns instant client managing this document.
-
getInstantDocumentDescriptor
@NonNull() abstract InstantDocumentDescriptor getInstantDocumentDescriptor()
Returns instant document handle for this document.
-
reauthenticateWithJwt
abstract void reauthenticateWithJwt(@NonNull() 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.
-
reauthenticateWithJwtAsync
@NonNull() abstract Completable reauthenticateWithJwtAsync(@NonNull() 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 .
- Parameters:
jwt
- JWT used to authenticate access to the document.- Returns:
Completable emitting failure when authentication fails and completion when authentication succeeds.
-
syncAnnotations
abstract void syncAnnotations()
Starts annotation sync and waits for its completion.
-
syncAnnotationsAsync
@NonNull() abstract Flowable<InstantProgress> syncAnnotationsAsync()
Syncs annotations with Instant Server (PSPDFKit Document Engine) asynchronously.
- Scheduler:
syncAnnotationsAsync
does not operate by default on a particular .
- Returns:
Flowable emitting annotations sync progress.
-
addInstantDocumentListener
abstract void addInstantDocumentListener(@NonNull() 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.
-
removeInstantDocumentListener
abstract void removeInstantDocumentListener(@NonNull() InstantDocumentListener listener)
Removes listener, previously registered via addInstantDocumentListener. 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. Addingnull
is not allowed,and will result in an exception.- Parameters:
listener
- InstantDocumentListener that should be removed.
-
notifyConnectivityChanged
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.
-
removeLocalStorage
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.
-
setListenToServerChanges
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.
-
isListeningToServerChanges
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.
-
getDelayForSyncingLocalChanges
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 (PSPDFKit Document Engine) or SYNC_LOCAL_CHANGES_DISABLED when automatic pushing of local changes is disabled.
-
setDelayForSyncingLocalChanges
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 (PSPDFKit Document Engine).
-
getDocumentState
@NonNull() abstract InstantDocumentState getDocumentState()
Returns the current state of this Instant document.
- Returns:
Instant document state.
-
-
-
-