Skip to main content

Creating and Viewing documents

A users documents can be managed using the User object. An instance of this object can be retrieved by using a login method on the CollabClient instance. See logging in users for more details.

Creating documents#

Documents are created with the User.createDocument API.

const document = await user.createDocument({
document: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
isPublic: true,
name: 'my_document.pdf'
})
  • options (CreateDocumentOptions)
  • options.document (Blob | File | URL) The document itself.
  • options.name (string) The name of the document
  • options.isPublic? (boolean, optional) Sets whether or not the document is public. More information here
  • options.id? (string | number, optional) If you want to assign a specific ID to the document, set it here. Otherwise, one will be generated by the database.

Returns an instance of Document.

note

Creating a document does not display it in the viewer. To display the document, use the document.view() function.

Viewing documents#

Once you have an instance of the Document object, you can call Document.view to display it in the viewer.

note

There are many ways to get an instance of Document. For more info, see getting user documents.

await document.view(file)
  • file (Blob | File | URL) The file you want to load. Since PDFTron Collaboration does not handle file storage, the actual document must be provided for display (see more info here)

Returns a promise that resolves once the file is loaded.

Getting documents#

See the getting user documents guide for more information on getting a list of a user's documents.