Skip to main content

Public documents

Public documents are documents with the isPublic flag set to true. They can be viewed by anyone, but can only be annotated by members of the document (by default).

To make a document public, you can use the Document.edit API, or pass the isPublic option when calling createDocument.

Creating a public document

const document = await user.createDocument({
document: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
isPublic: true,
name: 'my_document.pdf'
})

Editing a document to be public

await document.edit({
isPublic: true
})

Joining public documents#

Users have the ability to join public documents without an invite. This is required to annotate on the document.

To add the current user to a public document, use the Document.join API.

join(): Promise<boolean>#

Returns a promise that resolves to a boolean representing that the operation was successful. Throws an error if the document is not public.

Check if a user can join a document#

Before calling Document.join, you may want to check if the user is allowed to join the document.

To do this, use the Document.canJoin API.

canJoin(): Promise<boolean>#

Returns a boolean representing if the user can join the document.

const canJoin = await document.canJoin()
if(canJoin) {
document.join()
}

Getting a list of public documents#

A list of all documents can be fetched with the getPublicDocumentPaginator API.