Some test text!

Realtime collaboration basics

Contents

Host annotations in your own server
Host annotations in your WebViewer Server
Prerequisites
Integrate collaboration wvs package with Gradle
Integrate collaboration wvs package manually
Connect to the server

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 have a class that implements PDFTron's CustomService interface, it will contain an abstract method sendAnnotation for you to implement, for example:

  2. Annotations on the client side is represented by an AnnotationEntity object, it is required that your server data contains the following mandatory fields:

    • Unique identifier of the annotation
    • Unique identifier of the document that the annotation is in
    • Unique identifier of the author of the annotation
    • XFDF string of the annotation
    • (Optional) author name

    Once you have the above, a typical AnnotationEntity construction will look like:

  3. When data creation/modification/deletion events come in, you will construct the data into an AnnotationEntity object per annotation and add it to the local data structure. Note that all operations need to happen in the background thread:

    MethodDescription
    addUser(mDatabase, authorId, authorName)First, add the current user
    addDocument(mDatabase, documentId)Then, add the document that the collaboration is happening on
    addAnnotations(mDatabase, annotationEntityMap)Call this when your server notifies you of the initial batch of annotations that already exist on the document
    addAnnotation(mDatabase, annotationEntity)Call this when your server notifies you of created annotation
    modifyAnnotation(mDatabase, annotationEntity)Call this when your server notifies you of modified annotation
    deleteAnnotation(mDatabase, annotId)Call this when your server notifies you of deleted annotation
    cleanup(mDatabase)Call this when the session finishes
  4. In the same Activity where you added the viewer, add:

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

linkIntegrate collaboration wvs package with Gradle

  1. In your app module's build.gradle file (usually app/build.gradle), add a dependency to PDFTron collaboration wvs add-on package:

    dependencies {
      implementation "com.pdftron:collab-wvs:6.10.3"
    }

linkIntegrate collaboration wvs package manually

  1. Copy pdftron-collab-wvs.aar directly into your app module's libs directory. You will see other PDFTron AARs here such as pdftron-collab.aar

  2. In your app module's build.gradle file (usually app/build.gradle), add a dependency to PDFTron collaboration wvs add-on package:

    dependencies {
      implementation "com.pdftron:collab-wvs@aar"
    
      // okhttp
      implementation "com.squareup.okhttp3:okhttp:3.13.1"
    }

linkConnect to the server

In the same Activity where you added the viewer, add:

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

Contents

Host annotations in your own server
Host annotations in your WebViewer Server
Prerequisites
Integrate collaboration wvs package with Gradle
Integrate collaboration wvs package manually
Connect to the server