java.lang.Object | |||
↳ | androidx.fragment.app.Fragment | ||
↳ | com.pspdfkit.ui.PdfFragment | ||
↳ | com.pspdfkit.instant.ui.InstantPdfFragment |
Fragment that actually displays instant PDF document. It contains only the document view without any additional views like outline, thumbnail bar, search, etc. Meant to be used if you want full custom implementation and design.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | PARAM_INSTANT_DOCUMENT_SOURCE |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
InstantPdfFragment() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addInstantDocumentListener(InstantDocumentListener listener)
Adds a
InstantDocumentListener for instant document events. | ||||||||||
AnnotationPreferencesManager |
getAnnotationPreferences()
Returns manager for annotation preferences.
| ||||||||||
InstantPdfDocument |
getDocument()
Gets the loaded document.
| ||||||||||
UndoManager |
getUndoManager()
Returns this fragment's undo manager instance for performing undo/redo operations of edits.
| ||||||||||
static InstantPdfFragment |
newInstance(InstantPdfDocument document, PdfConfiguration configuration)
Creates and returns a new Fragment to display a PDF document from an already opened
PdfDocument instance. | ||||||||||
static InstantPdfFragment |
newInstance(String serverUrl, String jwt, PdfConfiguration configuration)
Creates and returns a new Fragment to display a PDF document downloaded from instant server.
| ||||||||||
void | onActivityCreated(Bundle savedInstanceState) | ||||||||||
void |
onAnnotationCreated(Annotation annotation)
Called when annotation has been created.
| ||||||||||
void |
onAnnotationRemoved(Annotation annotation)
Called when existing annotation has been removed.
| ||||||||||
void |
onAnnotationUpdated(Annotation annotation)
Called when existing annotation has changed.
| ||||||||||
void |
onAnnotationZOrderChanged(int pageIndex, List<Annotation> oldOrder, List<Annotation> newOrder)
Called when the z-order of annotations has changed on a specified page.
| ||||||||||
void | onAttach(Context context) | ||||||||||
void |
onAuthenticationFailed(InstantPdfDocument instantDocument, InstantException error)
Called when authentication with Instant server has failed.
| ||||||||||
void |
onAuthenticationFinished(InstantPdfDocument instantDocument, String validJwt)
Called when authentication with Instant server has successfully finished.
| ||||||||||
void | onCreate(Bundle savedInstanceState) | ||||||||||
View | onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) | ||||||||||
void | onDestroy() | ||||||||||
void | onDetach() | ||||||||||
void |
onDocumentCorrupted(InstantPdfDocument instantDocument)
Called when
InstantPdfDocument has detected data corruption. | ||||||||||
void |
onDocumentInvalidated(InstantPdfDocument instantDocument)
Called when
InstantPdfDocument becomes invalid. | ||||||||||
void |
onDocumentLoaded(PdfDocument document)
Called when document is successfully loaded and the document view has been laid out.
| ||||||||||
void |
onDocumentStateChanged(InstantPdfDocument instantDocument, InstantDocumentState state)
Called when the document changes its state.
| ||||||||||
void | onResume() | ||||||||||
void | onStop() | ||||||||||
void |
onSyncError(InstantPdfDocument instantDocument, InstantException error)
Called when annotation sync has been finished with an error.
| ||||||||||
void |
onSyncFinished(InstantPdfDocument instantDocument)
Called when annotation sync has been finished successfully.
| ||||||||||
void |
onSyncStarted(InstantPdfDocument instantDocument)
Called when annotation sync has been started.
| ||||||||||
void |
removeInstantDocumentListener(InstantDocumentListener listener)
Removes a previously added
InstantDocumentListener . | ||||||||||
void |
save()
Saves the annotations in opened document back to instant server.
| ||||||||||
void |
setHandleCriticalInstantErrors(boolean showCriticalErrors)
Sets whether the fragment should automatically handle certain critical Instant errors.
| ||||||||||
void |
setListenToServerChangesWhenVisible(boolean listenToServerChangesWhenVisible)
Controls whether to listen to server changes for loaded document when the fragment is
resumed.
| ||||||||||
void |
setOverlaidAnnotationTypes(EnumSet<AnnotationType> overlayAnnotationTypes)
Sets annotation types that should be rendered as overlays.
| ||||||||||
void |
syncAnnotations()
Starts syncing annotations back to instant server.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
List<Flowable<Double>> |
getDocumentLoadingProgressObservables()
Gets the list of loading progress observables.
| ||||||||||
Single<? extends PdfDocument> |
openDocumentAsync()
For internal usage only.
| ||||||||||
boolean |
shouldReloadDocument()
For internal usage only.
|
Adds a InstantDocumentListener
for instant document events. Listeners added with this
method will be removed automatically in onDetach()
. 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.
listener | Listener to be notified of instant document events. May not be null . |
---|
Returns manager for annotation preferences.
Note: This method must be called after views are created (after onCreateView(LayoutInflater, ViewGroup, Bundle)
).
Gets the loaded document.
Returns this fragment's undo manager instance for performing undo/redo operations of edits.
UndoManager
used for handling undo/redo operations on this fragment.
Creates and returns a new Fragment to display a PDF document from an already opened PdfDocument
instance. This will not reload the document.
document | An already opened instance of a PdfDocument object. |
---|---|
configuration | Configuration for PDF display generated with PdfConfiguration.Builder . |
Creates and returns a new Fragment to display a PDF document downloaded from instant server.
serverUrl | Url of the Instant server - used to initialize InstantClient . |
---|---|
jwt | Authentication token used to authenticate access to the document. |
configuration | Configuration for PDF display generated with PdfConfiguration.Builder . |
Called when annotation has been created.
annotation | Annotation that has been created. |
---|
Called when existing annotation has been removed.
annotation | Annotation that has been removed. |
---|
Called when existing annotation has changed.
annotation | Annotation that has been changed. |
---|
Called when the z-order of annotations has changed on a specified page.
pageIndex | Index of the page where the z-order has changed. |
---|---|
oldOrder | The old order of annotations on the page. |
newOrder | The new order of annotations on the page. |
Called when authentication with Instant server has failed.
instantDocument | Document that we were authenticating for. |
---|---|
error | Authentication error. |
Called when authentication with Instant server has successfully finished.
instantDocument | Document that we were authenticating for. |
---|---|
validJwt | JWT that was used for this authentication request. |
Called when InstantPdfDocument
has detected data corruption.
Receiving this callback means any further interaction with the sender’s document are destined to fail. You can copy the document package aside for forensic purposes, but you will — eventually — have to purge its storage, and download it anew.
Because this situation means the document has become unusable, it will invalidate itself immediately after this method returns.
instantDocument | Document that has detected data corruption. |
---|
Called when InstantPdfDocument
becomes invalid. Any future instant operations on this
document will fail.
instantDocument | Document that is becoming invalid. |
---|
Called when document is successfully loaded and the document view has been laid out. This has to be called on the main thread.
document | Loaded document instance. |
---|
Called when the document changes its state.
Note: After onSyncStarted(InstantPdfDocument)
, this method may be called multiple
times during the sync process.
instantDocument | Document which state has changed. |
---|---|
state | New document state. |
Called when annotation sync has been finished with an error.
The most likely reason is network failure REQUEST_FAILED
. Other
common reasons are expiration of your authentication token AUTHENTICATION_FAILED
, and cancellation USER_CANCELLED
.
instantDocument | Document that was syncing the annotations. |
---|---|
error | Error thrown while syncing annotations. |
Called when annotation sync has been finished successfully.
instantDocument | Document that was syncing the annotations. |
---|
Called when annotation sync has been started.
instantDocument | Document that is syncing the annotations. |
---|
Removes a previously added InstantDocumentListener
. After calling this method the
listener
will stop receiving instant document events. If the listener has not been
added previously, this method will be a no-op. Passing null
is not allowed, and will
result in an exception.
listener | Listener to unregister from instant document events. May not be null . |
---|
Saves the annotations in opened document back to instant server.
Sets whether the fragment should automatically handle certain critical Instant errors.
If true
, when this fragment is visible and a OLD_CLIENT
error occurs, an alert will be shown that tells the user the app must be updated. In
addition, if true
and a OLD_CLIENT
or OLD_SERVER
error occurs, automatic syncing will be disabled.
This defaults to true
. We recommended that you make your app handle all errors
that Instant might encounter, and then set this to false
.
Controls whether to listen to server changes for loaded document when the fragment is resumed.
listenToServerChangesWhenVisible | true to get immediate server updates when
fragment is visible. false to disable listening for server changes.
|
---|
Sets annotation types that should be rendered as overlays.
If annotation is not rendered as overlay, it is rendered within the page image. Rendering as overlay performs better if you frequently change annotations, but might delay page display and increase memory usage.
STAMP
annotations are always rendered as overlay in Instant that is
used to show placeholder while the annotation image data is being downloaded.
overlayAnnotationTypes | Annotation types that should be rendered as overlays. |
---|
Starts syncing annotations back to instant server.
For internal usage only.