PSPDFKit Instant Usage on Android
This guide will give you an overview of the Instant API and how to use it for displaying documents from the server.
The entry class into Instant is
InstantClient. This represents a connection to your PSPDFKit Server. An app typically creates one
InstantClient, although it could create several to connect to multiple PSPDFKit Server instances.
Instant manages downloading and storing PDF files when your app requests this. Each PDF file managed by Instant is identified by its
documentId and can have one or more named layers. Each layer represents a separate set of annotations displayed on top of the base document and is identified by its name.
In your app, each Instant layer is represented by an
InstantDocumentDescriptor instance that can be created by calling
getInstantDocumentDescriptorForJwt() on an
InstantClient. For each document layer, your app must obtain a JSON Web Token (JWT) from your server.
A document descriptor may be used to request downloading the associated PDF file and all annotations in the layer. Once that has finished, an
InstantPdfDocument may be created. Set this document on an
InstantPdfActivity and then show it to the user. Changes to annotations will be synchronized for all users viewing the same document.
InstantPdfFragment is a subclass of
PdfFragment, just as
InstantPdfActivity is a subclass of
PdfActivity, and both can be used to show only
InstantPdfDocument. Trying to display a
PdfDocument instance will result in an exception being thrown. Conversely, showing a
PdfDocument created by Instant in any activity or fragment not subclassing
InstantPdfFragment, respectively, is not supported.