create_and_begin
Create Collaboration
Collaboration is created with the webCollabClient.createCollaboration API.
const collaboration = await webCollabClient.createCollaboration({
fileUrl: 'https://foxit.com/downloads/pl/demo.pdf',
isDocPublic: true,
docName: 'demo.pdf'
})
options.fileUrl
: The URL of PDF document.options.docName
: The name of the document.options.isDocPublic?
: Sets whether or not the document can be allowed to open by everyone. True means allowed; false means not allowed.
tip
Creating collaboration will not automatically open the collaborative document, you need to call collaboration.begin()
API to open it.
Begin Collaboration
Once you have an instance of the collaboration object, you can call collaboration.begin to open it in the viewer.
Calling the method below will begin your collaboration:
await collaboration.begin(fileOptions?:{password:string, [key: string]: any})
tip
- An optional
fileOptions
parameter can be passed in to specify options when opening a PDF file. - For example, in order to open an encrypted PDF file,
fileOptions.password
is needed.
await collaboration.begin().catch(e => {
if(e.error === 3){
const passwordForPDF = await promptForPassword()
await collaboration.begin({
password: passwordForThePDF
})
}
})