DsPdfViewer allows you to share a PDF document with other users. The document can be shared in view or/and edit mode and can be worked upon by multiple users in real time. You can also observe the presence of other users and the changes made by them in the shared document, known as real-time collaboration.
The below image shows a PDF document in shared mode which has been edited by multiple users and their changes are visible along with their user names.
Once configured to use the SupportApi, a PDF document can be edited in following ways:
The collaboration mode, where multiple users can work on a shared document, is designed to work only with persistent client connections. To ensure this, the SupportApi includes the following nuget package dependencies:
When a shared document is modified, the server-side SupportApi code instantly pushes the changes to connected clients as soon as the changes become available. The steps listed below describe how to set up collaboration mode in ASP.NET Core Web Application and ASP.NET WebForms Application:
Note: Using SupportApi in ASP.NET Core projects requires ASP.NET Core 3.0 or later. For more details on how to upgrade an existing ASP.NET Core 2.2 project to 3.0, refer this link.
When you make changes to PDF documents in shared mode, the modified documents are stored in server's memory by default. These changes are discarded in either of the below cases:
To prevent this, you can do any of the following:
You can share a PDF document by clicking on the 'share' button in DsPdfViewer's toolbar.
To add the 'share' button in toolbar, use the following code:
Index.cshtml |
Copy Code
|
---|---|
viewer.toolbarLayout.viewer.default = ["share"]; viewer.applyToolbarLayout(); |
When you click on 'share' button, the 'Manage Access' dialog box opens as shown below:
You can provide access to other users and set their permissions to 'View only' or 'View and Change'.
You can also change the access of existing users or stop sharing the document with them.
You can open a shared PDF document by using the 'Shared Documents' panel. This panel lists all the documents that the current user has shared and has access to, with information about the access mode.
To add the 'Shared Documents' panel to the sidebar panel, use the following code:
Index.cshtml |
Copy Code
|
---|---|
var viewer = new DsPdfViewer("#root", { supportApi: 'api/pdf-viewer'} ); viewer.addSharedDocumentsPanel(); |
When multiple users collaborate in a PDF document at the same time, you can see the real-time changes along with the name of users. Whenever a shared document is opened, the ‘shared mode’ label with the document's access type is shown on the top right corner of the document, as shown below:
You can also use "sharing" option in API to configure document sharing options, like:
Index.cshtml |
Copy Code
|
---|---|
var viewer = new DsPdfViewer("#root", { userName: "John", sharing: { disallowUnknownUsers: true }, supportApi: "api/pdf-viewer" } ); |
Index.cshtml |
Copy Code
|
---|---|
var viewer = new DsPdfViewer("#root", { userName: "John", sharing: { knownUserNames: ["Jaime Smith", "Jane Smith"], disallowUnknownUsers: true, }, supportApi: "api/pdf-viewer" }); |
Index.cshtml |
Copy Code
|
---|---|
var viewer = new DsPdfViewer("#root", { sharing: { knownUserNames: ['Jamie Smith', 'Lisa'], presenceColors: { 'Anonymous': '#999999', 'Jamie Smith': 'red', 'Lisa': 'blue' } }, supportApi: "api/pdf-viewer" }); |
Index.cshtml |
Copy Code
|
---|---|
// change presenceMode to 'others': var viewer = new DsPdfViewer("#root", { sharing: { presenceMode: 'others' }, supportApi: "api/pdf-viewer" }); |