public final class

InstantClient

extends Object
java.lang.Object
   ↳ com.pspdfkit.instant.client.InstantClient

Class Overview

The entry point to PSPDFKit Instant, representing a client’s connection to the Instant server.

Summary

Public Methods
static InstantClient create(Context context, HttpUrl serverUrl)
Creates instant server client that is going to connect to server at serverUrl.
static InstantClient create(Context context, URL serverUrl)
Creates instant server client that is going to connect to server at serverUrl.
synchronized static InstantClient create(Context context, String serverUrl)
Creates instant server client that is going to connect to server at serverUrl.
String getDataPath()
Returns the data path the client was created with.
synchronized InstantDocumentDescriptor getInstantDocumentDescriptorForJwt(String jwt)
Returns the document descriptor matching the data encoded in the given JWT.
synchronized List<InstantDocumentDescriptor> getLocalDocumentDescriptors()
Returns document descriptors for locally cached documents.
String getServerUrl()
Returns the server URL the client was created with.
InstantPdfDocument openDocument(String jwt)
Downloads and opens document from instant server synchronously.
Single<InstantPdfDocument> openDocumentAsync(String jwt)
Downloads and opens document from instant server, asynchronously.
synchronized void removeLocalStorage()
Removes local storage for this client.
synchronized void removeLocalStorageForDocument(String documentId)
Invalidates all layers of the document with the given ID and removes its local storage.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static InstantClient create (Context context, HttpUrl serverUrl)

Creates instant server client that is going to connect to server at serverUrl.

Parameters
context The context to use
serverUrl Instant server url.
Throws
InstantException when creating the client fails. This can happen due to permission errors or disk corruption

public static InstantClient create (Context context, URL serverUrl)

Creates instant server client that is going to connect to server at serverUrl.

Parameters
context The context to use
serverUrl Instant server url.
Throws
InstantException when creating the client fails. This can happen due to permission errors or disk corruption

public static synchronized InstantClient create (Context context, String serverUrl)

Creates instant server client that is going to connect to server at serverUrl.

Parameters
context The context to use
serverUrl Instant server url.
Throws
InstantException when creating the client fails. This can happen due to permission errors or disk corruption

public String getDataPath ()

Returns the data path the client was created with.

public synchronized InstantDocumentDescriptor getInstantDocumentDescriptorForJwt (String jwt)

Returns the document descriptor matching the data encoded in the given JWT.

Parameters
jwt The JWT defining the document and its layer. Obtain this from your backend.
Throws
InstantException when the JWT cannot be parsed, the data on disk could not be accessed (e.g. due to permission errors, or data corruption), or when the data on disk belongs to another user than what is encoded in the JWT.

public synchronized List<InstantDocumentDescriptor> getLocalDocumentDescriptors ()

Returns document descriptors for locally cached documents. You can use this to access documents that are already downloaded and cached on the device, even while the device is offline.

Returns
  • List of locally cached document descriptors.

public String getServerUrl ()

Returns the server URL the client was created with.

public InstantPdfDocument openDocument (String jwt)

Downloads and opens document from instant server synchronously.

Parameters
jwt The JWT defining the document and its layer.
Returns
Throws
InstantDownloadException when server document download fails.
InstantException when the document data on disk could not be accessed (e.g. due to permission errors, or data corruption), or when the data on disk belongs to another user than what is encoded in the JWT.

public Single<InstantPdfDocument> openDocumentAsync (String jwt)

Downloads and opens document from instant server, asynchronously.

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

Parameters
jwt The JWT defining the document and its layer.
Returns
  • Single returning opened InstantPdfDocument or an error when document could not be downloaded or opened.

public synchronized void removeLocalStorage ()

Removes local storage for this client. This includes all documents and other client data. All opened documents will get invalidated.

Use this method to remove locally cached Instant documents when you no longer need them on the device (e.g. when signing out).

Throws
InstantException when removing local storage failed.

public synchronized void removeLocalStorageForDocument (String documentId)

Invalidates all layers of the document with the given ID and removes its local storage.

Use this method to remove locally cached data for a single Instant document when you no longer need it on the device.

Throws
InstantException when removing local storage failed.