Some test text!

menu
Connect to serverkeyboard_arrow_down

Realtime collaboration server

A server can be setup to be the backend that hosts all your files and annotations to use realtime collaboration with PDFTron SDK.

Realtime collaboration basics

This tutorial only applies to Xamarin.Android.

linkHost annotations in your own server

In realtime collaboration, a server will merely act as an online database that triggers events upon data creation/modification/deletion. As long as the above requirement is met, your server can be built in any language and stack of your choice. PDFTron provides an interface that will allow you to connect your data to the out-of-box UI.

  1. Your will need to obtain a reference to CollabManager from the CollabViewerTabHostFragment, then setup the current collaboration session, for example:

    void HandleTabDocumentLoaded(String tag)
    {
        // setup the current collaboration session
        var collabManager = mPdfViewCtrlTabHostFragment.CollabManager;
        if (collabManager != null)
        {
            collabManager.SetCurrentUser(mUserId, mUserName);
            collabManager.SetCurrentDocument(mDocumentId);
            collabManager.SendAnnotationEvent += (sender, e) =>
            {
                // local change, send info to server here
            };
        }
    }
  2. When your server notifies the client about remote changes, import the XFDF command string with CollabManager:

    void ImportXfdf(String xfdfCommand) {
        var collabManager = mCollabViewerTabHostFragment.CollabManager;
        collabManager.ImportAnnotationCommand(xfdfCommand);
    }

The annotations appearing on the document in real time are managed through a separate XFDF format, while the original version of the document is preserved on the server. Note that the client downloads the original untouched document at the start of the collaboration session.

And that is it! PDFTron will handle all annotation syncing and annotation reply for you.

See a detailed tutorial on an example of how to use Firebase as backend here: How to Build an Android Real-time Document Collaboration App with Firebase.

linkHost annotations in your WebViewer Server

If you are using WebViewer Server as backend, PDFTron provides a utility add-on package that will have realtime collaboration working out-of-box with your WebViewer Server. The following tutorial will go through how to add and use this package.

linkPrerequisites

Insall:

NuGet for Collab-WVS

linkConnect to the server

In the same Activity where you added CollabViewerTabHostFragment, add the following:

private BlackBoxConnection mBlackBoxConnection;
private CollabViewerTabHostFragment mCollabViewerTabHostFragment;
private string WVS_ROOT = "MY_WVS_ROOT_ADDRESS";
private string mFileUrl = "MY_DOCUMENT_URL";
private string mShareId = "MY_SESSION_ID";

protected override void OnCreate(Bundle savedInstanceState)
{
    base.OnCreate(savedInstanceState);

    mBlackBoxConnection = new BlackBoxConnection();

    CreateViewerFragment();
    mCollabViewerTabHostFragment.TabDocumentLoaded += (sender, e) =>
    {
        HandleTabDocumentLoaded();
    };
}

public void CreateViewerFragment() {
    // Create your CollabViewerTabHostFragment host fragment
    // and instantiate mCollabViewerTabHostFragment
}

private void HandleTabDocumentLoaded() {
    mBlackBoxConnection.CollabManager = mCollabViewerTabHostFragment.CollabManager;
    mBlackBoxConnection.Start(WVS_ROOT, DEFAULT_FILE_URL, DEFAULT_SHARE_ID);
}

protected override void OnDestroy()
{
    base.OnDestroy();

    mBlackBoxConnection.Stop();
}

Where:

  • WVS_ROOT is the address of your WebViewer Server instance
  • mFileUrl is the Url to the file to be collaborated on
  • mShareId is a unique identifier for an existing collaboration session, pass null to generate a new session

And that is it! PDFTron will handle all annotation syncing and annotation reply for you.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

Join our live demo to learn about use cases & capabilities for WebViewer

Learn more
close