Skip to main content

Loading documents

Documents can be loaded with the loadDocument function.


Using WebViewers initialDoc option will not work for collaboration purposes

This function has the same API as WebViewer's loadDocument function, so you can just swap the object you call it on from the Webviewer Instance to your CollabClient instance.

client.loadDocument(doc, options): Promise<{id, name}>
  • doc (Blob | File | URL) the document to load
  • options (LoadDocumentOptions) load document options. See the options section below for requirements.

This function will load the document and its annotations into the viewer. It will also subscribe to realtime events that happen on this document (new annotations, new users, etc).

If the ID provided does not exist in the database, a new collaboration session will be created using that ID.

The function returns a promise that resolves with the documents ID and name.


All documents are private by default. To make a document public, you can use the isPublic option, or the editDocument API.


import CollabClient from '@pdftron/collab-client'
const client = new CollabClient({
await client.loadDocument('', {
documentId: 'abcde',
filename: 'document.pdf'




When loading a document, it is important to pass the documentId option.

Passing documentId in the options let the client know which annotations, memberships, etc it needs to load from the database for that specific document.

If documentId is provided but does not exist in the database, a collaboration session will be created using that ID.

If documentId is not provided at all, a new collaboration session will be created using a generated ID.


The client will do its best to extract a name from the document you provide, however in certain scenarios it is not possible to get a file name.

It is recommended to pass the filename option to the loadDocument function as well.


If you are calling loadDocument for for the first time using this ID (aka creating a document), this will set whether or not the document is public. The default value is false.

This property is only used when creating new documents. It is ignored for existing documents.

Next steps#