Open PDFs Using PSPDFKit Server

To load a document from PSPDFKit Server, you’ll need to pass the document’s ID, the JSON Web Token (JWT) for authentication, and information as to whether or not PSPDFKit Instant should be enabled in the configuration object passed to PSPDFKit.load():

PSPDFKit.load({
	documentId: "<document_id>",
	authPayload: { jwt: "<jwt>" },
	instant: true
});

The <document_id> placeholder in the code above should be replaced by the identifier of an existing document on PSPDFKit Server. See the server API documentation for information on how to upload documents.

The <jwt> placeholder should be replaced with a valid and signed JWT. See the Generate a JWT guide for details.

The instant option configures whether or not PSPDFKit Instant should be enabled. PSPDFKit Instant is a real-time collaboration platform that enables your users to annotate documents simultaneously using PSPDFKit across iOS, Android, and their browser.

Accessing a Password-Protected Document

To load password-protected PDFs, you can provide the password option in the configuration.

Alternatively, clients can access password-protected PDFs by using a JWT that includes the password claim, or by supplying the password when opening or loading a document.

If the password is neither included in the JWT nor set via the configuration, the user will be asked to enter the password via a password prompt.

Password prompt shown for the password protected document.

Loading Options

You can open files in any of the supported file formats: PDF, JPEG, PNG, and TIFF (for both Standalone and Server-backed deployments) and Word files (for Server-backed deployments only).

PSPDFKit.load() also accepts different configuration options:

Example:

PSPDFKit.load({
  documentId,
  authPayload: { jwt: "<jwt>" },
  instant: true,
  toolbarItems: PSPDFKit.defaultToolbarItems.filter(item => item.type !== "print"),
  initialViewState: new PSPDFKit.ViewState({
    sidebarMode: PSPDFKit.SidebarMode.THUMBNAILS
  })
})